C program to find largest and smallest of three numbers

Find the largest and smallest of three numbers


Write a C program to find the largest and smallest of three numbers. Here’s simple program to find the largest and smallest of three numbers in C Programming Language.

In this program, Firstly, we are going to take input of three numbers from the user and then check for the condition which number is larger or smaller and then print the result on the screen.


Below is the source code for C program to find the largest and smallest of three numbers which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :


/*  C program to find largest and smallest of three numbers  */

#include<stdio.h>
int main()
{
    int n1, n2, n3;
    printf("ENTER FIRST NUMBER A :: ");
    scanf("%d", &n1);
    printf("\nENTER SECOND NUMBER B :: ");
    scanf("%d",&n2);
    printf("\nENTER THIRD NUMBER C :: ");
    scanf("%d",&n3);

    printf("\nTHE BIGGEST NUMBER IS :: ");
    if( (n1 > n2) && (n1 > n3) )
    printf("%d", n1);
    else if(n2 > n3)
    printf("%d", n2);
    else
    printf("%d", n3);
    printf("\n\nTHE SMALlEST NUMBER IS :: ");
    if( (n1 < n2) && (n1 < n3) )
    printf("%d", n1);
    else if(n2 < n3)
    printf("%d", n2);
    else
    printf("%d",n3);

    return 0;
}

OUTPUT : :


/*  C program to find largest and smallest of three numbers  */

ENTER FIRST NUMBER A :: 4

ENTER SECOND NUMBER B :: 7

ENTER THIRD NUMBER C :: 9

THE BIGGEST NUMBER IS :: 9

THE SMALlEST NUMBER IS :: 4

Above is the source code for C program to find largest and smallest of three numbers which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

Leave a Reply