Posts

Showing posts from September, 2020

C Program to check greater of three numbers.(using if-else)

C Program to check greater of three numbers. (Entered by User) # include <stdio.h> int main () { double a, b, c; printf ( "Enter three numbers: " ); scanf ( "%lf %lf %lf" , &a, &b, &c); // checks if a is greater than b and c if (a >= b && a >= c) printf ( "%.2lf is the largest number." , a); // checks if b is greater than a and c else if (b >= a && b >= c) printf ( "%.2lf is the largest number." , b); // checks if c is greater than a and b else printf ( "%.2lf is largest of three number." , c); return 0 ; } OUTPUT Enter three numbers: 8 9.9 -5 9.90 is largest of three number. EXPLANATION In above program  (a >= b && a >= c)  checks if a is greater than b and c if   if condition satisfies above condition then printf function returns value a as the maximum value of three numbers. Similarly if  (b &g