This article is from solution of Let Us C by Yashwant Kanetkar. I also posted many another articles regarding solutions of Let Us C. If you have any problem regarding solution then give comment, I will surely reply your question.
Q. Write a program to find the range of a set of numbers. Range is the difference between the smallest and biggest number in the list.
Ans.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int num, max=-32768, min=32767, range;
char choice='y';
while(choice=='y')
{
printf("\nenter any number ");
scanf("%d",&num);
if(num>max)
max=num;
if(num<min)
min=num;
printf("\nYou Want To Add Another Number(y/n) ");
fflush(stdin);
scanf("%c",&choice);
}
range=max-min;
printf("Range Is %d",range);
getch();
}