Ques 1 : WAP that accepts the marks of 5 subjects and finds
the sum and percentage marks obtained by the student
#include <stdio.h>
int main() {
int m1, m2, m3, m4, m5, sum;
float percentage;
printf("Enter marks of 5 subjects: ");
scanf("%d%d%d%d%d", &m1, &m2, &m3, &m4, &m5);
sum = m1 + m2 + m3 + m4 + m5;
percentage = (sum / 5.0);
printf("Total = %d\n", sum);
printf("Percentage = %f\n", percentage);
return 0;
}
Ques 2 : WAP that calculates the Simple Interest and
Compound Interest. The Principal, Amount, Rate of Interest
and Time are entered through the keyboard.
#include <stdio.h>
#include <math.h>
int main() {
float p,r,t,SI,CI;
printf("Enter Principal, Rate and Time: ");
scanf("%f%f%f",&p,&r,&t);
SI = (p * r * t) / 100;
CI = p * pow((1 + R / 100), t) - p;
printf("Simple Interest = %f\n", SI);
printf("Compound Interest = %f\n", CI);
return 0;
}
Ques 3 : WAP to calculate the area and circumference of a
circle.
#include <stdio.h>
int main(){
int r;
float pi = 3.14159265359;
printf("Enter radius of circle : ");
scanf("%d",&r);
float area = pi*r*r;
printf("Area of circle = %f\n",area);
float circumference = 2*pi*r;
printf("Circumference of circle = %f",circumference);
return 0;
}
Output :
Ques 4 : WAP that accepts the temperature in Centigrade and
converts into Fahrenheit using the formula C/5=(F-32)/9
#include <stdio.h>
int main(){
int temp;
printf("Enter Temperature (in C) : ");
scanf("%d",&temp);
float temp_f = (9*temp/5) + 32;
printf("Temprature (in F) : %f",temp_f);
return 0;
}
Output :
Ques 5 : WAP that swaps values of two variables using a third
variable
#include <stdio.h>
int main(){
int a,b,temp;
printf("Enter a : ");
scanf("%d",&a);
printf("Enter b : ");
scanf("%d",&b);
printf("a = %d and b = %d, before swapping\n",a,b);
temp = a;
a = b;
b = temp;
printf("a = %d and b = %d, after swapping",a,b);
return 0;
}
Output :
Ques 6 : WAP that checks whether the two numbers entered
by the user are equal or not.
#include <stdio.h>
int main(){
int a,b;
printf("Enter first number : ");
scanf("%d",&a);
printf("Enter second number : ");
scanf("%d",&b);
if(a==b){
printf("Entered Numbers are Equal");
} else {
printf("Entered Numbers are not Equal");
}
return 0;
}
Output :
Ques 7 : WAP to find the greatest among three numbers.
#include <stdio.h>
int main(){
int a,b,c;
printf("Enter a,b,c : ");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c){
printf("%d is greatest",a);
} else if (b>c){
printf("%d is greatest",b);
} else {
printf("%d is greatest",c);
}
return 0;
}
Output :
Ques 8 : WAP that finds whether a given number is even or
odd.
#include <stdio.h>
int main(){
int a;
printf("Enter the number : ");
scanf("%d",&a);
if(a%2!=0){
printf("%d is odd",a);
} else {
printf("%d is even",a);
}
}
Output :
Ques 9 : WAP that tells whether a given year is a leap year or
not?
#include <stdio.h>
int main(){
int year;
printf("Enter year : ");
scanf("%d",&year);
if((year%400 == 0)||(year%4==0 && year%100 !=0)){
printf("%d is a leap year",year);
} else {
printf("%d is not a leap year",year)
}
return 0;
}
Output :
Ques 10 : WAP that accepts marks of five subjects and finds percentage and
prints grades according to the following criteria: Between 90-100%-----Print ‘A’
80-90%-----------------Print ‘B’ 60-80%-----------------Print ‘C’ Below 60%-------------
Print ‘D’
#include <stdio.h>
int main(){
int m1, m2, m3, m4, m5, sum;
float prcnt;
printf("Enter marks of 5 subjects: ");
scanf("%d%d%d%d%d", &m1, &m2, &m3, &m4, &m5);
sum = m1 + m2 + m3 + m4 + m5;
prcnt = (sum / 5.0);
printf("Total = %d\n", sum);
printf("Percentage = %f\n", prcnt);
if(90<prcnt && prcnt<100){
printf("A");
} else if(80<prcnt && prcnt<90){
printf("B");
} else if(60<prcnt && prcnt<80){
printf("C");
} else if(prcnt<60){
printf("D");
}
}
Output :