#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf
int main()
{
int m, n;
for(m =2; m <=4; m++)
for(n = 5; n >= 3; n--)
p("%d\n", m + n);
getch();
return 0;
}
Write a program that will display "IT'S COLD!" if the temperature is less than 20, "IT'S HOT!" if the temperature is greater than 30, "COOL CLIMATE!" otherwise.
#include<stdio.h>
#include<conio.h>
#define p printf
#define s scanf
int main()
{
int T;
p("Enter temperature: ");
s("%d",&T);
if ( T < 20 )
{
p("IT'S COLD!");
}
else
if ( T > 30 )
{
p("IT'S HOT!");
}
else
{
p("COOL CLIMATE!");
}
getch ();
return 0;
}
Write a program to determine the equivalent grade of each student in a class as follows:
a. Read in the student's name, midterm grade, minor B, and final exam ratings. b. Determine the final grade of the student by formula: final grade = 0.30 of midterm grade + 0.10 of minor B + 0.60 of final exam. c. Determine the equivalent grade for the numerical value obtained by the following grading marks:
Write a program that gives discount of 100 pesos to a costumer if shirt bought is XL and the price is greater than 500; a discount of 50 pesos if the shirt bought is large and the price is greater than 400.
(Solution)
#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf
Write a program that will input a student's grade and will display "Congratulations you PASSED!" if the student's grade is greater than or equal 60. Otherwise "Sorry you FAILED!".
#include<stdio.h>
#include<conio.h>
#define p printf
#define s scanf
int GRADE;
int main( )
{
p("Enter Grade of Student:");
s("%d",&GRADE);
if(GRADE >= 60)
p("Congratulations you PASSED!");
else
p("Sorry you FAILED!");
getch();
return 0;
}
Write a program that asks the user to enter a number n and display the first even numbers. Example: if n=5, the first 5 even numbers are 2, 4, 6, 8 and 10.
(Solution)
#include<stdio.h>
#include<conio.h>
int main( )
{
int ONE, TWO;
printf("Enter Number: ");
scanf("%d",&TWO);
for (ONE=0; ONE<=TWO; ONE+=2)
{
printf ("%d\n",ONE);
}
Write a program that asks the user to enter a number n and display the first odd numbers. Example: if n=5, the first 5 even numbers are 1, 3, 5, 7 and 9.