Greatest Number

#include<stdio.h>

int main() {
	int a, b, c, d;
	printf("\nEnter 4 number for comparison:\n");

	/* Received more than one integer type value from user */
	scanf("%d %d %d %d",&a, &b, &c, &d);

	/* If condition for checking greatest value from two variables */
	if(a > b) {

		/* If 'a' is greater than 'b' */
		if(a > c) {
			if(a > d)
				printf("Greatest Number is: %d\n", a);
			else
				printf("Greatest Number is: %d\n", d);
		}
		else {
			if(c > d)
				printf("Greatest Number is: %d\n", c);
			else
				printf("Greatest Number is: %d\n", d);
		}
	}
	else {

		/* If 'b' is greater than 'a' */
		if(b > c) {
			if(b > d)
				printf("Greatest Number is: %d\n", b);
			else
				printf("Greatest Number is: %d\n", d);
		}
		else {
			if(c > d)
				printf("Greatest Number is: %d\n", c);
			else
				printf("Greatest Number is: %d\n", d);
		}
	}
	return 0;
}


/* Output */
Enter 4 number for comparison:
4
3
7
2

Greatest Number is

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!