You are on page 1of 5

[Q1]

WRITE A C PROGRAM THAT CAN TAKE 3 NUMBERS FROM THE USER AND PRINT THE MAXIMUM
AMONG THEM (USING IF …ELSE IF LADDER)

*******INPUT : *******

#include <stdio.h>

int main()

int a, b, c, max, min;

printf("Enter any three numbers \n");

scanf("%d%d%d", &a, &b, &c);

if (a >= b && a >= c)

printf("The max is %d \n", a);

else if(b >= a && b >= c)

printf("Maximum is %d \n", b);

else if (c >= a && c >= b)

printf("Maximum is %d\n", c);

return 0;

}
*******OUTPUT : *******

[Q2] PRINT AND CALCULATE ADDITION ,SUBTRACTION ,MULTIPLICATION ,DIVISION,AND MODULO


OF TWO USING IF …ELSE IF LADDER

******INPUT *******

#include <stdio.h>

int main()

float a, b;

char x;

printf("Enter two numbers \n");

scanf("%f%f", &a, &b);

printf("Enter which operation you need to perform : [+,/,*,-,%%]\n");

fflush(stdin);

scanf("%c", &x);

if (x == '+')
printf("The summation is %f", a + b);

else if (x == '-')

printf("The subtraction is %f", a - b);

else if (x == '/')

printf("The division is %f", a / b);

else if (x == '*')

printf("The multiplication is %f", a * b);

else if (x == '%')

printf("The modulation is %d", (int)a%(int)b);

return 0;

*******OUTPUT : ********
[Q3] Write a C Program that takes the input of 5 Subjects marks. Count the average marks.
Print the overall result for the following conditions.
i. if the student has 70% or more than 70% then Distinction.
ii.
if the student has average marks

between 60 to 69 then First class.


iii.
if the student has average marks

between 50 to 59 then Second class.

iv.
if the student has average marks

between 40 to 49 then Pass class.


v.

if the student has average marks

less than 40 then Fail.

*******INPUT*******

#include <stdio.h>

int main()

float a, b, c, d, e;

printf("Enter the marks in 5 subjects obtained out of 100 \n");

scanf("%f%f%f%f%f", &a, &b, &c, &d, &e);

float x = (a + b + c + d + e) / 5;

printf("The average marks is : %f\n", x);

if (x >= 70 && x <= 100)

printf("The student is passed with distinction\n");


}

else if (x <= 69 && x >= 60)

printf("The student is passed with first class\n");

else if (x >= 50 && x <= 59)

printf("The student is passed with second class \n");

else if (x >= 40 && x <= 49)

printf("The student is passed\n");

else if (x < 40)

printf("The student is fail \n");

return 0;

*******OUTPUT*********

You might also like