Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to compare integers

I'm trying to solve this problem in chapter 1 of a C programming book. I want this program to read in 5 integers then determine and print the largest and smallest. My problem is I don't want it to print everything just the smallest and largest values. Is my comparison of the integers correct?



#include
#include

int main()
{
int a,b,c,d,e;

printf("enter your five numbers and I'll tell you something
");
scanf("%d%d%d%d%d", &a,&b,&c,&d,&e);

/* if(a>b)
printf("%d
",a);

if(a>c)
printf("%d
",a);

*/
if(a>b,c,d,e)
{
printf("%d
",a);
}
if(aa,c,d,e)
{
printf("%d
",b);
}
if(ba,b,d,e);
{
printf("%d
",c);
}
if(c
a,b,c,e)
{
printf("%d
",d);
}
if(d
a,b,c,d)
{
printf("%d
",e);
}
if(e<a,b,c,d)
{
printf("%d

",e);
}

«1

Comments

«1
Sign In or Register to comment.