Question
Please check, I am getting errors. #include #include //creating struct for storing student id and percentage struct student { int stuid; int per; } s[50];
Please check, I am getting errors.
#include
//creating struct for storing student id and percentage
struct student
{
int stuid;
int per;
} s[50];
//main program started
int main() {
//declaring variables char choice;
int count,i,j;
int n;
for(count=0; count<50; count++) { //for loop to read the grades till array size printf("-------------------sorting --------------- Sorting(s) Quit(q) "); scanf("%c",&choice); if(choice == 's') { //if user choice is s, then read the id number and percentage
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 the loop { 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started