Here are the directions:

Modify you grade book program to use a custom struct to hold thestudent’s ID number and the percentage score for each item in thegrade book. The program should accept the entry of ID numbers andpercentage grades (0–100) until the user signals that he or she isdone entering grades. The program should then print out the IDnumbers and grades entered by the user, sorted by ID number.

Here is the code:

#include <stdio.h>
#include <stdlib.h>
//creating struct for storing student ID and percentage
struct student
{
int stuid;
int per;
} s[50];

int main()
{
//variables
char choice;
int count,i,j;
int n;
int temp;
for(count=0; count<50; count++)
{ //loop to read the grades till array size
printf(“——————-sorting —————n Sorting(s) nQuit(q) n”);
scanf(“%c”,&choice);
if(choice == ‘s’)
{ //if user choice is s, then read the id number andpercentage
printf( “Enter id number”);
scanf(“%d”, &s[count].stuid);
printf( “Enter grade:”);
scanf(“%d”, &s[count].per);
//while loop for entering valid score
while(s[count].per>=0 && s[count].per<=100)
{
printf( “please enter a valid score between 0 to 100”);
scanf(“%d”, &s[count].per);
}
}
if(choice == ‘q’) //if the user choice is q, then exit theloop
{
break;
}
}
n=count;
//sorting struct based on student id number
for (i = 1; i < n; i++)
for (j = 0; j < n – i; j++)
{
if(s[j].stuid> s[j+1].stuid)
{
temp = s[j].stuid;
s[j].stuid = s[j+1].stuid;
s[j+1].stuid = temp;
}

printf(“student id and average scores are: “);
for(i=0; i<count; i++)
{
printf(“%d %d”, s[count].stuid, s[count].per);
}
return 0;
}
}

I am having problems with this code. The grade book compiles,but it does not run correctly. I don’t think the program’s printedinstructions for the user are clear about the program should beused. However, I do know the code has a properly defined struct touse for each grade entry. Even after the user enters a score withthe valid range, the program prompts the user again to enter thegrade, it continues to prompt for grades without asking again foran ID number. I know the program should be set up so that it asksfor an ID number and then the score for each entry but I’m not surehow to do that. I also don’t think the loops are not set upcorrectly for the sort, so the program does not produce sortedoutput. Please help.