EmbLogic's Blog

To find Largest and Smallest no.s among five numbers entered from the user

#include<stdio.h>
int main()
{
int a,b,c,d,e,largest,smallest;
printf(“enter five integers\n”);
scanf(“%d%d%d%d%d”, &a,&b,&c,&d,&e);
largest = a;
if (b > largest)
{
largest=b;
}
if (c > largest)
{
largest=c;
}
if (d > largest)
{
largest=d;
}
if (e > largest)
{
largest=e;
}
printf(“largest number is  = %d\n”,largest);
smallest = a;
if (b < smallest)
{
smallest=b;
}
if (c < smallest)
{
smallest=c;
}
if (d < smallest)
{
smallest=d;
}
if (e < smallest)
{
smallest=e;
}
printf(“smallest number is  = %d\n”,smallest);
return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>