Find out the range of marks number of N students .
Program:
#include<stdio.h>
int main()
{
int n, i, m, a[100], max, min;
while(scanf("%d", &n)==1){
//printf("How many students = ");
//scanf("%d", &n);
for(i=0; i<n; i++)
{
printf("Enter mark for [id %d]", i);
scanf("%d", &a[i]);
}
max=a[0];
min=a[0];
for(i=0; i<n; i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("Range %d to %d", min, max);
}
return 0;
}
Program:
#include<stdio.h>
int main()
{
int n, i, m, a[100], max, min;
while(scanf("%d", &n)==1){
//printf("How many students = ");
//scanf("%d", &n);
for(i=0; i<n; i++)
{
printf("Enter mark for [id %d]", i);
scanf("%d", &a[i]);
}
max=a[0];
min=a[0];
for(i=0; i<n; i++)
{
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
printf("Range %d to %d", min, max);
}
return 0;
}