Tuesday, February 5, 2019

Greatest between 3 numbers (Method 2)

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;
}
 

No comments: