Write a program in C to find the greatest of three numbers.
Code:
#include <stdio.h>
int main()
{
int a,b,c,max;
printf("Enter 3 integers:\n");
scanf("%d %d %d",&a,&b,&c);
max = a;
if(b>max) max = b;
if(c>max) max = c;
printf("%d is the greatest number.",max);
return 0;
}
Code:
#include <stdio.h>
int main()
{
int a,b,c,max;
printf("Enter 3 integers:\n");
scanf("%d %d %d",&a,&b,&c);
max = a;
if(b>max) max = b;
if(c>max) max = c;
printf("%d is the greatest number.",max);
return 0;
}
No comments:
Post a Comment