C Program to Find the Largest Number among Three Numbers

C Program to Find the Largest Number among Three Numbers

In this example, you'll learn c program to find the largest number among three numbers using if and logical and operator. For example, if the user has entered 80, -5, 3 then the output will be: 

80 is the largest number.

#include<stdio.h> 
int main()
{
    int n1, n2, n3;

    scanf("%d %d %d", &n1, &n2, &n3); 
    if( n1>=n2 && n1>=n3 )
        printf("%d is the largest number.", n1);

    if( n2>=n1 && n2>=n3 )
        printf("%d is the largest number.", n2);

    if( n3>=n1 && n3>=n2 )
        printf("%d is the largest number.", n3);

    return 0;
}


--------------------------------

NOTE: You have any problem in the above, C program to find the largest number among three numbers do not hesitate and write your problem in the comment box. I will support your problem.

No comments:

If you have any doubts, Please let me know

Powered by Blogger.