c program to find greatest of three numbers

 

c program to find greatest of three numbers


                  

Code: 

#include <stdio.h>
int main()
{
    int a,b,c;
    printf("Enter 1st Number:");
    scanf("%d",&a);
    printf("Enter 2nd Number:");
    scanf("%d",&b);
    printf("Enter 3rd Number:");
    scanf("%d",&c);
    if(a>b)
    {
        if(a>c)
        {
            printf("%d is greatest",a);
        }
        else
        {
            printf("%d is greatest",c);
        }
    }
    else 
    {
        if(b>c)
        {
            printf("%d is greatest",b);
        }
        else 
        {
            printf("%d is greatest",c);
        }
        
    }
    

    return 0;
}

 

Sample Input and Output:

Enter 1st Number:4                                                                                                                   
Enter 2nd Number:5                                                                                                                   
Enter 3rd Number:1                                                                                                                   
5 is greatest

 

If you any have doubt,suggestion regarding this post or website then feel free to share with us.
 
If you have learned something new from this post then share this post with your family and
friends.
 

Happy Learning :)😎   

Previous Next

3 Comments

Previous Post Next Post