Q:

C program to find largest and smallest of three numbers

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Number Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C program to find power of a number ( x^n ... >>
<< Write a C Program To find the biggest and smallest...