Howdy, Stranger!

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

Categories

How to compare integers

RadiationXRadiationX Member Posts: 6
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.