C program to Largest value among three variables

Below is C program to Largest value among three variables .

Program:

/* Largest value among three variables */

#include<stdio.h>
int main()
{
    int a,b,c;
    printf("Enter value of a: ");
    scanf("%d",&a);
    printf("Enter value of b: ");
    scanf("%d",&b);   
    printf("Enter value of c: ");
    scanf("%d",&c);       
   
    if(a >= b && a >= c)
        printf("%d is largest",a);
    else if(b >= a && b >= c)
        printf("%d is largest",b);
    else if(c >= a && c >= b)
        printf("%d is largest",c);
    return 0;
}

No comments:

Post a Comment