C Program to find greatest among four numbers.
Answer:
#include<stdio.h>
int main()
{
int num1,num2,num3,num4;
printf("Enter four numbers");
scanf("%d%d%d%d",&num1,&num2,&num3,&num4);
if(num1>num2&&num1>num3&&num1>num4)
printf("%d is greatest",num1);
else if(num2>num1&&num2>num3&&num2>num4)
printf("%d is greatest",num2);
else if(num3>num1&&num3>num2&&num3>num4)
printf("%d is greatest",num3);
else
printf("%d is greatest",num4);
return 0;
}
C Program to find smallest among four numbers.
Answer:
#include<stdio.h>
int main()
{
int num1,num2,num3,num4;
printf("Enter four numbers");
scanf("%d%d%d%d",&num1,&num2,&num3,&num4);
if(num1<num2&&num1<num3&&num1<num4)
printf("%d is smallest",num1);
else if(num2<num1&&num2<num3&&num2<num4)
printf("%d is smallest",num2);
else if(num3<num1&&num3<num2&&num3<num4)
printf("%d is smallest",num3);
else
printf("%d is smallest",num4);
return 0;
}