C Program to find the biggest and smallest of three numbers

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




The entered three numbers N1, N2, N3 are compared in such an order, where the first comparison checks if  N1  largest. If so, prints it out and exists; if not so, it omits N1 from further comparison and checks with N2 and N3 only. The same logic but with complement operator, the program finds the least among the three.

#include<stdio.h>
void main()
{
int n1, n2, n3;
clrscr();
printf(“nnt ENTER THREE NUMBERS A,B,C…(separated by commas): “);
scanf(“%d,%d,%d”, &n1, &n2, &n3);
printf(“nnt THE BIGGEST NUMBER IS…: “);
if( (n1 > n2) && (n1 > n3) )
printf(“%d”, n1);
else if(n2 > n3)
printf(“%d”, n2);
else
printf(“%d”, n3);
printf(“nnt THE SMALlEST NMBER IS…: “);
if( (n1 < n2) && (n1 < n3) )
printf(“%d”, n1);
else if(n2 < n3)
printf(“%d”, n2);
else
printf(“%d”,n3);
getch();
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program To find the biggest and smallest number and positions in the given array
  2. C program to find the biggest of three numbers
  3. C Program To find the fibonacci numbers below a given number.
  4. C Program to find the prime numbers between a given range
  5. C Program to find the prime numbers below a given number.

Leave a Comment

Previous post:

Next post: