Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The idea here is a program that uses a sentinel loop and some comparison inside

ID: 3671283 • Letter: T

Question

The idea here is a program that uses a sentinel loop and some comparison inside the loop for some simple number processing. You are to create a program that has this interaction - it uses all integer values: That if the numbers arc entered with the larger number first they are "ordered" by being displayed in the reverse order. That the sentinel value is 0 0. not just one zero. That a sentinel loop works by using a priming read and a read at the bottom. That when the median value would be normally something like 2.5, it is rounded up rather than down. (Which is what integer division naturally does.) This one is a bit tricky to figure out, and it involves something we know about %2... that the overall range is calculated as the difference between the largest number entered the smallest number entered throughout the run of the program

Explanation / Answer

#include<stdio.h>
int main(){
int a ,b,c ;
printf("Enter Your numbers or 0 0 to quit:");
scanf("%d%d",&a,&b);
if(a==0 && b==0)
{
goto avi;
}
if(a>=b)
printf("Orderd these numbers are %d%d ",b,a);
else
printf("Orderd these numbers are %d%d ",a,b);
if(a%2==1)
a=a+1;
if(b%2==1)
c=(a+b)/2;
printf("The median is : %d",c);
avi:
return 0;
}