0

/*QUESTION 2*/

```
/*Program to compute frequency of a list of marks obtained by a group of students*/
#include <stdio.h>
#define SIZE 100
main()
{
/*define n as number of students.x[SIZE] is a array to store marks of students*/
/*tempo[SIZE] is also used to store marks, but used in computation for frequency*/
/*In tempo[SIZE], elements are first arranged in ascending order to facilitate
the computation of frequency*/
int i, j, n, temp, x[SIZE], tempo[SIZE];
/*read in the value of n, the number of students*/
printf("\n How many students?");
scanf("%d", &n);
printf("\n\n");
/*Ask user to input marks*/
for(i=0; i<n;++i){
printf(" MARKS %d:", i+1);
scanf("%d",&x[i]);
tempo[i] = x[i];
printf("\n");
} /*End of for loop*/
/*display for frequency*/
/*reorder all array elements in ascending order*/
for(i=0; i<n-1; ++i){ /*beginning of outer for loop*/
/*find the smallest of all the remaining elements*/
for(j=i+1; j<n; ++j){ /*beginning of inner for loop*/
if(tempo[j]<tempo[i]){
/*interchange two elements*/
temp = tempo[i];
tempo[i] = tempo[j];
tempo[j] = temp;
} /*end of if statement*/
} /*end of inner for loop*/
} /*end of outer for loop*/
/*computation of frequency*/
printf("\t");
return 0;
}
```