C program to Find the Largest Number Among Three Numbers

 Find the Largest Number Among Three Numbers :


 This is a C program to calculate the  largest number of three numbers;

Flow Chart For Finding Largest Number :


Program (Source Code):

This program uses only if else  statement to find the largest Number ;

Example 1:

#include <stdio.h>
void  main()
{
    int a,b,c;
    printf("Enter  Three number: ");
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    // Logic of largest Number .

    if (a>b && a>c)
        printf("%d  is largest number.",a);
    if (b>a && b>c)
        printf("%d  is Largest number.",b);

    else
        printf("%d  is largest number.",c);


}

Output:



This program uses  nested if-else statement to find the largest number :
Example 2:

#include <stdio.h>
void  main()

{
    int  n1, n2, n3;

    printf("Enter three numbers:\n ");

    scanf("%d %d %d", &n1, &n2, &n3);

    if(n1+=n2 && n2==n3 && n3==n1)
   {
          printf(" The Number are Equal:");

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

    }
    else
   {
        
        printf("%d is the largest number.", n3);

    }
}


Output:














Though, the largest number among three numbers is found using multiple ways, the output of all these program will be same.

Other Program 

* Introduction To C Programming! 
* If-Else # Nested-If-Else-statement In C Programming !



 Thanks of Reading .

Like / Comment / Share 



*

Post a Comment (0)
Previous Post Next Post