Question: What's wrong with my code:(C language) //Objective: To get 4 integers and infer the smallest and largest values. { int first,second,third,fourth,bigger1,bigger2,smaller1,smaller2,biggest,smallest; printf(Enter four integers: );

What's wrong with my code:(C language)

//Objective: To get 4 integers and infer the smallest and largest values.

{ int first,second,third,fourth,bigger1,bigger2,smaller1,smaller2,biggest,smallest; printf("Enter four integers: "); scanf("%d %d %d %d",&first,&second,&third,&fourth);

{if (first>second)

{bigger1=first; smaller1=second;} else bigger1=second; smaller1=first;}

{if (third>fourth) {bigger2=third; smaller2=fourth;} else bigger2=fourth; smaller2=third;}

{if (bigger1>bigger2) biggest=bigger1; else biggest=bigger2;}

{if (smaller2>smaller1) smallest=smaller1; else smallest=smaller2;}

printf("Biggest: %d ",biggest); printf("smallest: %d ",smallest);

return smaller1;

//I can't get the correct smallest value.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!