C Programming

Greatest and smallest of three numbers using nested if

A simple program to check the greatest and smallest number and display the same as output. This can also be implemented in a more efficient way using Sorting algorithms.

Language : C

[sourcecode language='c']
#include
#include
void main()
{ int a, b,c;

printf(“Enter the value for A: “);
scanf(“%d”, &a);
printf(“Enter the value for B: “);
scanf(“%d”, &b);
printf(“Enter the value for C: “);
scanf(“%d”, &c);

if((a>b)&&(a>c)
printf(“Largest is A!”);
if else ((b>a)&&(b>c))
printf(“Largest is B!”);
else
printf(“Largest is C”(;

getch();

}
[/sourcecode]



{ 1 comment… read it below or add one }

1 sameer September 23, 2010 at 4:54 am

can we found the greatest and smallest number among three inputed number at a time

Reply

Leave a Comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.


WordPress - Vaibhav Kanwal