C program to find largest number using if…else statement

/* C program to find largest number using if...else statement */
 
#include <stdio.h>
int main() {
	float a, b, c;
	printf("Enter three numbers: ");
	scanf("%f %f %f", &a, &b, &c);
	if (a >= b)
	{
		if (a >= c)
			printf("Largest number = %.2f", a);
		else
			printf("Largest number = %.2f", c);
	}
	else
	{
		if (b >= c)
			printf("Largest number = %.2f", b);
		else
			printf("Largest number = %.2f", c);
	}
	return 0;
}
Capture.PNG
Output
 
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s