0 like 0 dislike
4.7k views

Write a program with following requirements:

  • Define the structure type student with fields: name, code, and grade.
  • Write a function to sort the structures in grade ascending order and another function to display the data of the students who got a higher grade than the average grade of all students. If there is only 1 student in the list, display the data of that student.
  • Write a program that uses this type to read the data of 100 students and store them in an array of such structures. If the user enters the grade −1, the insertion of student data should terminate. Then print the data of the students who got a higher grade than the average grade of all students. 

 Example input:

Edgar
20161123
78
Robert
20161523
75
Rebecca
20166123
66
Todd
20161673
86
End
1
-1

Example output:

Students who got a higher grade than the average grade of all students:
Name: Edgar
Code: 20161123
Grade: 78
Name: Todd
Code: 20161673
Grade: 86

 

[Exam] asked in Midterm
ID: 23789 - Available when: Unlimited - Due to: Unlimited

reshown by | 4.7k views

70 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <string.h>



struct student_grade{
** * *** * * ***** * *** * code[100],grade[100];
* * ***** ******** ** name[100][100];

};



int main()

{
* **** * * ** * * * sum=0;
* **** * * * * * ** ** i, j;
***** ** ** *** ** *** * student_grade s1;


* ** * ** * * * * ****** * *** *
*** *** ** * *** *** * * ***** **** * **** ** ** * * * %d * **** * **** * ** * * * ** *
* *** * ** * **** * ** ** * * * * * * **** * ** == -1)
*** * ** * * ** * ** * * *** ** ** ** ** ** ** ** ****** **
* * * ** * *** * * * ** ** *** ***** **** * * *
** ** * ** * * * *
* * * *** ***** ** * **** /= (float)i;
* ** * * ** * * ***** * * who got a higher grade than the average grade of all students:\n");
** *** ** * * ** * * * *** ***
** *** * ** * **** ** ** ** ** *** * * ** * *** ** >= sum){
* * ** * * * ** ** * * ********* * * * ** *** *** %s\n",s1.name[j]);
* * * **** ** * * * * * ** ** ** ** * ** *** *** * **** * * * * *** ** %d\n",s1.code[j]);
*** * *** * ******* ********* * * ** * ******** * * ***** * ** * *** %d\n",s1.grade[j]);


* * **** * * * * *** * * * * ** * **
** * * *** * *** * **



}
answered by (237 points)
0 like 0 dislike
Hidden content!
include<stdio.h>

#include<string.h>

typedef struct

{
* ** * ** * **** ****** * name[20];
** * * * * ** num;
* ** * ***** * ** grade;



}data;

int main(void)

{
* ** * * * * ****** sol[100];
* * ** * ** ** * ** ** ***** ** *
* *** * * ** *** *** i,j,sum;
* * * * * * ** * **
*** *** ** * * ** *
* ** ** ** * ** * **

    {
** * ** ** ** * * ** * ** * ** * ** * * *** * *** * * ** *** ** ***
*** ** **** ** ** *** * **** **** * * * ** **** *** * * * *
**** * ** ** * ** * *** * *** ** * ** *** * * ** * ** *


* * ****** *** * ** * * * * * *** ** **** * * *** ** *
** ** ** * ** *** ** * * * *** * ** * *
** **** * * * *** ** * * * ******** * * ******* * ** ******* **
* * ** * * * *** * * * ****** * * * * * * ** ** *
***** * **** * * ***** * *** * * ** * * * * *** * * * * *
* * ****** * *** * **** ***** ** * *** *

    }
***** ** * *** * * ** **** * who got a higher grade than the average grade of all students:\n");
* ** * * ** *** ** * * ****** * *

    {


* * ** **** * * ***** * **** ** ** **** * ********** ** *****
* * *** * * * * * ** * * *****
* *** ** ** ** * *** *** ** * ** ** *** * * * * ** ** * * * * ****** * %s\n",sol[j].name);
** ** * * * ** ** ** * * * ** * **** * * *** * * ** * *** *** * * * ** ** %d\n",sol[j].num);
** * ** * ** * ***** * *** ** * **** ** ******* *** ** * * * * ***** **** ** %d\n",sol[j].grade);
** ** ** * * *** ** ** ***** * * ** *** * * *** **

    }
* ** ***** *** *** 0;





}
answered by (0 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

typedef struct

{
*** * ******* ** *** * ** * name[20];
** ** ** **** ** **** num;
* * * ******* * grade;



}data;

int main(void)

{
* *** * * ** * * * * * sol[100];
*** *** * **** ** **** * ******* * * * ***
* ** * *** ***** *** * * * * i,j,sum;
** *** ***** * * * * * **
** *** * * * * ***
*** * * * ** *** * * * **

    {
** * * *** **** **** * ****** * ***** ******* ***** *
* **** ** * * **** ** * ** ** * **** ** * *** * *** * * *** * * * ****** *
* * ** * ** * ** ** *** *** * * * * *** ** ** * **** * ** ** ****** **


* ******* ** * * ** ** * * ** ** * * * *** * *** * *** *
** ** ** *** ** * ***** ******* ** ***** *
* *** * *** ***** * ** * ** *** * * * * ***** * * ** * * *
*** *** * * ** *** * * ** *** * *
* * *** ** **** ** * *** ******** * * * ** *
* ** * ** ** * ** *** ** * ** * ** *** * *

    }
*** ** *** **** * * **** * * ****** * * who got a higher grade than the average grade of all students:\n");
* * ** * ** * * * ** * *

    {


* * * ********* * * *** ** * ** ** ** * **** * *** *
***** * ** *** ** *** ** * * *** **** * * * *
**** ** * * * * ** * *** * *** * * **** ** **** *** * *** * ** * * *** ** %s\n",sol[j].name);
* * **** * **** ** * ***** * ** *** ** ** **** * *** * * **** ** ** * * %d\n",sol[j].num);
* * *** ** * *** * * * * * * * ** ** * ** * * * **** * * * *** *** * * %d\n",sol[j].grade);
** * ** * ** * * * **** **** **** **

    }
* ** *** * * * * ******* *** %d\n",sum/i);





}
answered by (0 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



struct student

{
** **** * **** * * * ** * n[10];
* * ** **** * * ** c[8];
* *** * *** ** *** * * * g;

};



int main()

{
** *** ******** * student s[100], ss[100], c;
**** **** * * *********** ** i, j, k, a, b;
**** * ** *** ** ** avg;
* * *** *** * ** ** *** **** i<100; i++)

    {
** **** ** * **** * * **** * ** * ** **** ***** * *** * ** ** s[i].n);
* *** ** * * * * **** ** ****** * * *** * ** * * * * s[i].c);
* * ** **** ***** ** * ** * **** * * *** *** *** * *** ** &s[i].g);
* **** * ** * * * ** * *** * *** * * ** == -1) break;

    }
* * * * ** ** * ** * * *** * avg=0; j<i; j++)
* * ******* *** ******* **** * ** ** *** * *** += s[j].g;
* * ******* *** * * = avg/i;


** * * * * ** *** * * **** k=0; j<i; j++)
* * ** ** ** * * *** **** ** *** ** > avg)
* * **** * **** *** **** ** * ** * * ** **
********** *********** ** *** ** * **** * * * * * **** ** **** ** = s[j];
* ***** ** * * ** ** * * * * ***** ** * ***** * ** *** *** * * ****
**** * * ** * ** * ** * ** ** ***** **** *
** *** * ****** **** * a<k; a++)
* *** * * ** * ** * ** ** ** * b<k; b++)
* * ** ** ****** * * ** * ** ** *** * * *** ** ** * ** * ****** * >ss[b].g)
** * ** * * ** *** * ** * * **** ** ** *** ** **
**** * * * * * * * ** * *** * * * ** * ** * ** * ** * * ** * * *** * * = ss[a];
* * * *** *** *** * ** * * ** ** **** ** * **** ** * * ** *** * * ** *** * * **** ****** * = ss[b];
* * * * *** * * *** * * *** * *** *** * ***** ** ** * * * * * *** ****** ** * *** * *** = c;
* * ** * ** * ** * ** * * ** * ** *** **** ** * ** * * * **


**** *********** * *** ***** ** who got a higher grade than the average grade of all students:\n");
* ** * * * * * ** * ** ** ** j<k; j++)

    {
* * *** ** *** *** ****** ** ** * * ** *** * ** ** *** * %s\n", ss[j].n);
***** ** * ** *** ** * ** *** ** * ** *** * * ** %s\n", ss[j].c);
* ** **** ***** * ** *** *** ** ** * * ** ** * * %d\n", ss[j].g);
** * *** * * *****


*** * *** ** * * * **** 0;

}
answered by (-364 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <string.h>



struct student_grade{
* ****** **** * * * * *** code[100],grade[100];
* * *** * *** ** * ** *** ** name[100][100];

};



int main()

{
** **** * ** *** * * * ** sum=0;
* *** ** **** * i, j;
*** ** ** * * * ** **** student_grade s1;


* ** *** **** ** * ******* *** * **
*** ** * *** ** * * *** *** **** *** %d * * * * * ** ** * * * *** *** ******
* * ** *** * * * * * * ** ** * ****** **** * == -1)
** * *** ** *** * ****** * ***** * * *** * * * * ** * *** * * *** *
* *** * * ** * *** ** * *** * * * ** * ** *** *** ** *** *
** ** * ** * ****** *
**** * ** ** * ** **** /= (float)i;
**** *** ** * **** * * * * ** ** who got a higher grade than the average grade of all students:\n");
** * ** * * ** * ** *** *** ** ***
* ** * ** * * * * * *** * *** *** ******* * ** * * >= sum){
* ** ** ** ****** **** * **** **** * * * * * *** * * * * * *** ** ** * %s\n",s1.name[j]);
* * ** *** *** ** * * ***** * ** *** ** ** * * * ** * * *** * * * * ** %d\n",s1.code[j]);
**** * ** **** ** ** * * * * *** * *** * * * * ** * ** ** * * * *** ** %d\n",s1.grade[j]);


** * * * *** * * * * ** * * **
* **** ** *** *** *



}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

typedef struct stdlist

{
* * * * *** ** * ***** ** name[100];
*** * * * *** * * ** * code[100];

    int grade;

}a;

int output(int i,struct stdlist people[])

{

    int a,b,sum=0;
**** * * ** * ** * ****** ** **** *****

    {
**** ** * **** ** * * ** * ** * * **** **
** * *** ***** * *** * ** * **** ** ** * **** *
* ** *** * ** * * ** *** ** ***** ** * *** * *** * * ** ** * *** * ** *** ** *
** * * ** * * ***** * * * ****** *** ** ********* *****
* * *** * *** * * *** ** * *** ** ****** ****** * *** ** * ** ** * * * * ** ****** ** stdlist change=people[b];
** * ** ** * * * ** ** * * ** ** *** ** * * * ** * ** * ** * * *** **** ** ***** * * * ** * * *** * *
* * ** * * *** **** * ******* * * *** *** * **** *** ******** * *** * * *** * *********
***** * **** ** ** **** * * * * *** * ** **** ** ** **
* ****** * ** ***** * * ***** * * * * ***** * *

    }
**** * ** ** **** * ** ** ***

    {
* ***** * ** * * * * *** * ****** ** * ** *** * *** *

    }
* * * * **** ** * * ** * * who got a higher grade than the average grade of all students:\n");
***** * *** ** * *** * *

    {
* * ******* ** ** * *** * *** * *** * *** ** ** * * %s\nCode: %s\nGrade: ** ** *** ** * ** **** * * * *

    }
*** *** * * *** *

    {
** ** ** * * ** * *** * ** * *** ** ** * ** **
* * ** * * * *** * * ***** * * *
* * *** *** * ** ** * *** * * ** **** *** ** *** ** *** * * ** ** ** ** **
*** ***** ***** ** ** **** * * * ** *** * ** *** ** ** ***


** ** *** * *** **** ** ******** * ** * *** * ** **** ** *** ** ** *** ** * * %s\nCode: %s\nGrade: ***** ** * * * * ******* * * ****
* ** ***** * * ** ** ** *** ** * ***

    }

}

int main()

{
* * * ** ** * *** a=1,i=0;
******* ***** * ** *** **** stdlist people[100];
* ** **** * * ****** **

    {
*** * * ****** ** * **** * ** ********** * ** ** ** *
* * * * * ** *** *** ** * ** * *** * *** ** * ***** ** * ** *** ******
* * ** * **** * * * * * * * ***** * * * * * * * *** * * *
** ** *********** * * ** **** * * * * ** *** *
**** ** **** ** ** * * * ** ** **** * ** * ** * *
* * ** *** * **** * *** * * * ** ******** *** * * *
* ** * * * * * ** ***** ***** * * * *** * *** *** *** * * **
*** * ** ** * ** ** ** * **** ** **** *****
* * ** * ** ***** * * ** * * *** ****

    }
*** * * *** * ** ** ** * **** *

}
answered by (-366 points)
0 like 0 dislike
Hidden content!
*** *** ***** ******* * *
* *** **

int main ()

{

  struct data

  {
* * **** * *** * * * * * * *** * * * * name[10];
** * ** ** * * *** **** * ********* ID;
* ** ** * * ** * * ** *** grade;
***** ** **** * *

  int i=0,j,sum=0,aver=0;
***** * *** ** ***** ** ** ****** **** * *
* * * * ** *** *** **** * *
**** ** * **** * * * ** * *** ** **** ** ** *
** ** ** * **** ** **** * * *

  {
***** **** **** *** ** *** ** *
**** * * * ** * ** *** * ** ** ** ** *** ** ** * * **
*** *** * * ** *** **** * * * ** * * *** ******* * ****
** ** * * * **** ** ** * ** *** ********* ** * ** *** * ** * **

  }
* ** ** ** ** * * ** ***

  {
* * * * ** ** * ** *** * * * **** * * *** *

  }
*** **** ** *** **
*** ** * * *** * * ** who got a higher grade than the average grade of all students:\n");
* * * ******

  {
* *** *** * * ** * ****** * * * * **** ****** * *** * *
** ** * * ** * * **** * ***** **
* * * ** ** ** * ***** *** * ** * ** ** * * %s\nCode: %d\nGrade: * * * * * ** ** * *
* * ** * * *** **** * *** * * * **

  }

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
* ** * * * * * **
** ** * * *

int main ()

{

  struct data

  {
** * *** * ****** * * ** ** * name[10];
** * * *** *** * * ** * * ** ** ** * ID;
** ** ** * * ** **** ** *** **** grade;
**** ***** ** * * ***

  int i=0,j,sum=0,aver=0;
* ** * ****** * * *** * * *** * * **
*** *** * * *** ** * ** *** ** ****** * **** ***
** **** * **** * * *** ** * ** *
* * *** * * **** ** **** ** **

  {
********* ** ** * ** *** * *** ****
** * ** * * *** * * ***** ** * * * * * ** ** **** ***
* * * * * *** * * * ** ** * * * *** ** ****** * **** *****
* ** * ** ** * * * * ** * * ** * * ** ** *** * * * * *

  }
* * * ***** * * ***

  {
** * * *** *** * * ******** * * **** ** * * **

  }
*** * * *** ***
*** *** * **** who got a higher grade than the average grade of all students:");
** ** ** ** ** ** ** * *

  {
* ** * *** ***** * * * * *** * * **** ** *
* * * *** * *** * * * *** * *
* * * **** ** ** * * ** * *** ** ***** * * * ** * * %s\nCode: %d\nGrade: *** * ***** *** * **** ** ****** *** * * *
* ** * * * *** **** ******

  }

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
* **** * * *** *** ****

int main ()

{

  struct data

  {
* ****** * ***** * ** ** ** name[10];
* * ** * * * * * **** * ID;
* **** * * * *** * ** ** *** *** grade;
** ** * * * ***

  int i=0,j,sum=0,aver=0;
* *** * ** ****** * *** * * * * * * * *
** * * * * ** * * * * ** ** *
*** **** * **** * * ** * ******
** * * **** * * * ******

  {
* *** * ** * *** *** * ********** ** ** *
* * * ** * * ** ** ** * *** * *** *** * * **** * * * * * ****
*** * * *** ** ** ** * * ********** * * *** ** * * * *** * * *
********* ** *** *** ******** ** ** ** * * * ** *** * * **

  }
** *** * ***** * ***

  {
* ** *** * *** ** * ** * *** * ***

  }
* * ******
** * *** * ***** ** *

  {
* * ** *** ** * * **** *** * * ** * ** *
* **** ***** **** * *** * * *
* * * * ** * ** ******** ** ***** *** * * * * * *** ** %s\nCode: %d\nGrade: *** ** ** * * * * ** **** * * *
*** * * ** ******** **** * ** ** * * **

  }

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <string.h>



struct student_grade{
*** ** * *** * * code[100],grade[100];
* ** *** * * **** *** name[100][100];

};



int main()

{
** *** *** *** * * * sum=0;
** **** ** * * * ** i, j;
** ** * * * * ***** student_grade s1;


****** * ******* ******* * *** *
*** ** * * ** ** ** ** * * ** * ** ** * **** ****** %d ** * * ** * ****** * * *** *
**** * * * * * ** * ***** ** ** * * * * ***** **** * == -1)
* ** ** * *** * ** * * ********** * ** ** * * * ** ***
* ** **** * * ** * ***** * * ** * ** ** * **** **
** * ** *** *****
** * ** * * *** * ** ** /= (float)i;
** ***** * * ** * ** ** ** ** ** * who got a higher grade than the average grade of all students:\n");
*** *** **** ** * * ***** * *** *
* ** * * * ** ** *** * * * * * ** * **** >= sum){
** *** **** ** * *** *** * ** **** ** * *** * * * * * ***** *** ****** %s\n",s1.name[j]);
* * * *** * * ** ** **** * ** ****** * * * *** * * * * ** *** * %d\n",s1.code[j]);
*** ** * **** * **** ****** ** *** ** * * * ***** **** ** * ** * %d\n",s1.grade[j]);


** *** *** * ** * * ** * * ** * **
** *** ** **



}
answered by (126 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.131.10
©2016-2025

Related questions

0 like 0 dislike
8 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24273 - Available when: Unlimited - Due to: Unlimited
| 845 views
0 like 0 dislike
6 answers
[Normal] asked Apr 21, 2017 in Midterm by thopd (12.1k points)
ID: 24271 - Available when: Unlimited - Due to: Unlimited
| 722 views
0 like 0 dislike
13 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24269 - Available when: Unlimited - Due to: Unlimited
| 1.2k views
0 like 0 dislike
46 answers
asked Apr 13, 2017 in Midterm by thopd (12.1k points) | 3.2k views
0 like 0 dislike
44 answers
[Exam] asked Apr 13, 2017 in Midterm
ID: 23785 - Available when: Unlimited - Due to: Unlimited
| 3.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users