Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int num1, num2, num3, num4, max;
- /* Input three numbers from user */
- printf("Enter first number: ");
- scanf("%d", &num1);
- printf("Enter second number: ");
- scanf("%d", &num2);
- printf("Enter third number: ");
- scanf("%d", &num3);
- printf("Enter fourth number: ");
- scanf("%d", &num4);
- if(num1 > num2)
- {
- if(num1 > num3)
- {
- max = num1;
- }
- else
- {
- max = num3;
- }
- }
- else if(num2>num4)
- {
- if(num2 > num3)
- {
- max = num2;
- }
- else
- {
- max = num3;
- }
- }
- else
- {
- if(num3 > num4)
- {
- max = num3;
- }
- else
- {
- max = num4;
- }
- }
- /* Print maximum value */
- printf("Maximum among all four numbers = %d", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement