0 like 0 dislike

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
Available when: Unlimited - Due to: Unlimited
| 4 views

8 Answers

0 like 0 dislike
Hidden content!
#include * * * **

#include * * *******



struct student_grade

{
* ** * *** ** * *** ** code[100], grade [100];
** ** ** * * ** ** ** * ** * * * **

};

int main()

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


**** * ** ***** * *** i<100; i++)
* * * ** * * ** ** *
* ** ** * * * ***** * * * ** * **** ** * ** %d %d", s1.name[i], * * ** * * ** ** *
* * * * * * * ****** * ** ** ******* ** **
* ***** * * * * ** * * *** **** *** **** * * * ** *** ** * * * *** ** * **
**** * * * * *** * *** * ** * ** ** * * * * *** **
** *** * * * ** * ***


* *

{
* * *** * ***** *** ** **** * * * who got a higher grade than the average grade of all * * ** **

}

for(j=0; j<i; j++)

{
* * * **** **** ** * ** ****** ** *
* ****** * **** **
* * * ** * ** * ** *** *** * * ** * * ***** ****** %s\n", s1.name[j]);
* * * ** ** * * ** * ***** ** *** ** * ** *** * *** * s1.code[j]);
*** *** * *** * ** ***** ** * * * * ** *** **** * * * %s\n", s1.grade[j]);


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

}

}
answered by (-48 points)
0 like 0 dislike
Hidden content!
#include ***** * ** **

#include ** * * **

#include **** ** ** ***

#define MAX 100



struct student{

char name[25];

int id;

int grade;





};





void sort(struct student e[],int n){

int i;

int j;



for * ****** **

for * *** *
* ** * **** * ** *** ** *** **** *** * * * * * *** *** * *
** * ** ** **** * * ** ***** ** *** * ** **** * *** ** ********** student temp=e[j];
*** * * ***** ** * *** * * ** * * * * **** ** * * * *
* * * ******* * * *** * **** * *** * * * * * * ****** *** * **** * *
* * **** * ** * *** **** * **** * *** ***



}





}

}

void *** student e[],int n){

int i;

int avr=0;



for * *
****** * * ** * * * * * * **** ** *

}

avr=avr/n;

for ** * *** **
*** * ** * ** ** ** ** ** ** ** *
* ** ****** * ** * ** * * * * * ******* * ** ***** **
* ** ****** * * ***** * ******* * * * * * **
**** * ** * *** * ***** * * * ***** *** *
* * * * * * ****

}

}





int main(){



struct student e[MAX];

int n;

int i;



for ***** *
******* * * * *** * * * * **
* ** **** ** * * * *** ****** *** ***** *
*** ** ** * * * * *** * ** ** *** * * ******* * * ******* *
*** * * * *** ** * * * ***** **
* * * * **** *** ***** ****** * * ** ** * *

}

}

n=i;

if (n==0)
* *** * ** * * ** *
* * * * * ** ****** * ** * ** *** * * ** * * * * *
* * ** *** *** *** * * ** **** * ** *
* **** ** * * ** ****** ******* ** *** * * *
****** *** * *** ** * ** *

else

{


* * * **


* * ** * * *** who got a higher grade than the average grade of all * * * ** ******


* ** **

}

return 0;}
answered by (-34 points)
0 like 0 dislike
Hidden content!
#include * * ** *

#include *** * *

#define MAX_STR 50

#define MAX_STUD 100



typedef struct{
* * ** *** * * *** ** **** name[MAX_STR];
** **** *** ****** ** ** code;
* ******* * * * ** * grade;

}Student;



int main(void){
*** * * *** * ** ** *** ****
** ** * ** * * * * i, count=0, sum=0;
** *** *** *** ** * avg;


*** * *** * ** **** ** ** * i<MAX_STUD; i++){
* *** ** *** * ** *** *** ** * * * * * ******* * ** * * * * * **
* * * ** * **** * * **** * * ** * * * ** **** ** ** *** * *
* **** * ** *** * ** ********** * * *** ** * * *** * ** ** *** ** * * * **
**** ** ** * * * ** * * * ** ** *** * **
* * * ** *** * ** * ** **** ** ** ** **** += students[i].grade;
* * ** * * *** *** *** * * ** ** *** ** * *** **** == -1)
**** * * * ** * * * * ** * * * * * ** * ** * * * ** ** * * *** * *****
** **** ** * ** * *
** ******** * * *** * ** * * = (sum+1)/(count-1);
* ***** * *** * * * * *** * ** ** * * who got a higher grade than the average grade of all **** ** * *


* ** ** * *** * * * ** **** i<count; i++){
** * * * * * * * * *** ***** ** **** *** * * ** > avg)
* ***** *** ***** * * ** * **** ** * *** ** * * ** * **** * ***** ** * * %s\nCode: %d\nGrade: %d", students[i].name, students[i].code, ** * * **
*** *** * ** ** * * * *


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

}
answered by (20 points)
0 like 0 dislike
Hidden content!
#include * * ****

#include * *** ***



struct Student{
**** **** ** **** ** ** ** name[20];
* ** * * *** * * *** *** id[20];
*** **** * * *** *** grade;

};



typedef struct Student Student;



int main(){
** **** ** ***** * i;
** ***** * * ** * lenght = 0;
* * *** * ****** total = 0;
** ** * *** ** ** ** average = 0;
* * * * * **** * * * list[100];


* * ***** ** * ** *** * i<100; i++){
** *** * *** * ** ** * ** ** * ** * * * * list[i].name);
** ** ** ** ** * *** **** *** *** **** ***** **** * list[i].id);
* * * * ** * * *** ** * *** ** * **** * ** * * *** * * ** *
** * ** **** **** **** * * * * * * < 0)
** * * * * ** ** ** ** * ** *** ***** * **** **
* * ** *** * **** *** * ***


*** * ** * *** ****** ** = i;


**** **** * *** * **** ** i< lenght; i++){
* **** * ** * * * ********** * *** ***** * * ** += list[i].grade;
* * **** * * *** * **


* ** ** *** *** ** * = total / lenght;


* * * * *** * ** **** * * *** * ** who got a higher grade than the average grade of all ** ***
* ** ** * ** ** ** * ** *** * * i++){
** ** * * *** * * * * *** * * * * ** **** * *** > average){
* * ** * *** *** * * * ** * ***** ** ** * * ** * **** **** **** **** ** *** %s\n", list[i].name);
** ** * * ** * * * ** * * *** **** *** * *** * * * ** *** **** ** ** **** * ** *** %s\n", list[i].id);
** * **** ** * ****** * * ** * *** * *** * * * ** * * **** * * * * %d\n", list[i].grade);
* * * *** ***** *** * ** ** ** **
** ** * *** * * * *


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

}
answered by (-188 points)
0 like 0 dislike
Hidden content!
#include *** * * **

#include * * * **** **



struct Student{
* * * ** *** * * ** * name[20];
*** ***** * * * **** ** id[20];
*** ** * ***** * * grade;

};



typedef struct Student Student;



int main(){
* ***** **** **** ***** i;
* * * * **** * lenght = 0;
** *** ** *** * * *** total = 0;
* * * ** *** * ** average = 0;
* * * ** ** ** *** ***** * * list[100];


* ******* **** ** ** ** i<500; i++){
* * * * *** **** ** * ** * * * * ** * * * ** list[i].name);
******* * ** * * * * ** * * **** * *** ** * ** list[i].id);
** **** **** * ** * ** *** * **** ** * **** * * * *** ** *** **
* * * * * *** *** * * * ** ** ** **** < 0)
* * * * ** * **** * * * ** * * * * ** *** *
* * ** *** ** * ***


* * * **** * ***** * * ** = i;


* ***** * **** * * *** *** ** i< lenght; i++){
** ** * * ***** * ** * ** ** ** * * *** * += list[i].grade;
* * ** ** *** * ** **


* * *** * ** **** = total / lenght;


* * ** * *** *** ** *** * * * * who got a higher grade than the average grade of all **** **** **
* **** * * * ** * ** * * ** ** * * i++){
* * * *** * * **** *** ** * * * * * * * * > average){
* * *** ** * * * * * * * ****** * * ** * * * * ***** * * *** *** * ** %s\n", list[i].name);
** * ** ****** * ** ***** * * **** * * ***** * * * *** ****** ******* ***** %s\n", list[i].id);
** *** * * **** * * * ** * * ** **** *** ** ****** * ** * ** *** **** ** ** * %d\n", list[i].grade);
* *** ** * * ** ** **** ** * * * * ****
* * *** ** * ** * * *


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

}
answered by (-188 points)
0 like 0 dislike
Hidden content!
#include * * ****

#include * *** ** * *



struct Student{
** * * * * * * * * name[20];
*** **** *** * * ****** id[20];
* * ** ** * *** * *** ** grade;

};



typedef struct Student Student;



int main(){
** * *** ** ** *** * * i;
**** * ****** * * lenght = 0;
* * ** ** *** ** * * *** ** total = 0;
* * * * ** * average = 0;
** ** ** * * * * * ** *** list[100];


* **** * * * **** i<500; i++){
* * ** * * *** * *** *** ** *** * ** list[i].name);
* **** ** * **** ** * *** * * ** * * *** * *** ** * list[i].id);
* * ** ***** ** *** * * * * * * * ****** ** ***
* * * * ** ** *** * *** * * * * * * * ** < 0)
** * * ** * ** *** ** ** * ** ** *** *** *
* ** ******** ** * * * *** *** *


* * ** ** * ** * * * = i;


* ** ** * * ** * * *** * * ** i< lenght; i++){
* * * * *** * ***** *** * * ** ** *** * * += list[i].grade;
* *** *** *** *** *


* ** * * * *** *** ******* * ** = total / lenght;


* ** * * ** *** * ** *** ** **** * who got a higher grade than the average grade of all * * ** *****
** * * * *** ** * * * *** i++){
* * *** ** * * * ******* * * ** ** *** * *** *** > average){
**** * ***** * * **** ** * * * * ***** ***** ** * * ** * ** *** %s\n", list[i].name);
*** *** * ******** ** ** *** *** ** * *** * * ** * **** * *** ** **** * %s\n", list[i].id);
** ** * ** ** ** * ** * * ** ** * * * * * *** ** * * * * *** ** ** %d\n", list[i].grade);
** * ** *** * * * ** * ****** * * **** * * *
**** * * **** * ** ** * ****


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

}
answered by (-188 points)
0 like 0 dislike
Hidden content!
#include **** ** * **

#include * *** *** *



struct Student{
*** * * ** *** * ** * name[20];
** * * ** **** *** * *** id[20];
** *** * ** *** * grade;

};



typedef struct Student Student;



int main(){
* ** ** ** * * * *** i;
* * * ** ** * * * * * * lenght = 0;
**** * **** * *** * *** total = 0;
* **** * ***** ** ** average = 0;
**** * * ** ** * ** list[100];


* * ** * ** *** * * i<500; i++){
*** ** ** * * ** ***** ** * * * * * ** ** **** list[i].name);
* * * *** **** ** ** **** ***** * * list[i].id);
* * * ***** *** ** * ** * * * ** * ** * * **** * ** * *
* ** ***** * ** * ** * * * * **** == -1)
* ** **** * **** * * * ** * * ** * * * **
* * ** ** ** *


******** * * * ** ** * * * = i;


***** * * * ** *** * i< lenght; i++){
** ** ** ** *** ******** *** *** ***** * += list[i].grade;
* * * ** * * *** *


** ** *** ** * * * ** * *** = total / lenght;


* ** * ** * ** * ******* * * * * ** who got a higher grade than the average grade of all * * *** *
** **** ** ** ** *** ** ** * ** i++){
*** * *** ** * ** * * * * *** **** *** * * * > average){
*** ** * * * ** ** * * ** ****** *** **** * *** ** * ** * ** * * ** * * * %s\n", list[i].name);
**** ** * * ** * ***** **** * * * ** ** **** ** *** *** * *** ** * %s\n", list[i].id);
* ** * * * * * * *** *** *** * **** * ** ** ** * * * * ** * * *** *** * * *** * **** %d\n", list[i].grade);
* *** ***** ****** *** * ** * * *
* * **** ** * ** ** * * *


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

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

#include ** * ***** ***



struct Student{
*** **** ** *** ** * ** name[20];
*** ***** ** * *** ** * id[20];
* ****** * * ** *** * grade;

};



typedef struct Student Student;



int main(){
** ** ** * *** * ** ** ** i;
** *** * **** ** * lenght = 0;
* * * ** *** * * ** * average = 0;
** ** * ** * * * * *** *** list[100];


* **** ** ** * ***** * ** i<100; i++){
* * ** ** *** *** **** * *** ***** * ** *** * list[i].name);
* * ** * * * * *** ** *** * ** * * * ******* list[i].id);
*** * * ******** ** *** * ** * *** * * ***** * ** *** * * * * ** *
**** * ** **** ** * * * ****** * ** * == -1)
** * * * * * ** * * * ** *** ***** * * ** ***
* ** *** * *** ** * *


* **** ***** * *** ** * = i;


* * * * **** * * * ** i<lenght; i++){
* * * * *** * ** ** * ** **** * ** ** * * * * * * ** ** ** list[i].name);
* ********* * * *** *** **** * * ** *** * * * * * list[i].id);
* * ** ** * ** ** ** ** ** *** ** ** * ** * * * *** list[i].grade);
* * *** ****** * * * ***


* * **** * ** ** *** ** i< lenght; i++){
* *** *** * * * * ** * ** * ** * * * *** ** ** * ** += list[i].grade;
* ** *** * **** ** ***** **


** * * *** * * * * = average / lenght;


** * ** ** ** *** * ** ** * ********* who got a higher grade than the average grade of all students:\n");
* *** ** * *** * ** *** * ** i<lenght; i++){
* ** * * * ** * * * ** ***** * * **** * * * ** * * * * * > average){
* * **** * * * * **** ** ** *** ** * * * * ** **** * **** ** * *** * * ** * ** list[i].name);
* **** ** *** * *** **** * * * *** * ** * ** * * ** * * **** * **** **** ** ****** list[i].id);
*** ***** ** *** * * ** * *** * * ****** * *** ** ***** *** *** ** * * ****** ** * ** ** list[i].grade);
**** * * ***** ** *** * * ** ** *** * *
*** * * * *** ** * *


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

}
answered by (-188 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.70.185
©2016-2019

Related questions

0 like 0 dislike
6 answers
[Normal] asked Apr 21, 2017 in Midterm by thopd (11.3k points)
Available when: Unlimited - Due to: Unlimited
| 23 views
0 like 0 dislike
13 answers
[Exam] asked Apr 21, 2017 in Midterm
Available when: Unlimited - Due to: Unlimited
| 4 views
0 like 0 dislike
70 answers
[Exam] asked Apr 13, 2017 in Midterm
Available when: Unlimited - Due to: Unlimited
| 5 views
0 like 0 dislike
4 answers
[Exam] asked Apr 21, 2017 in Midterm
Available when: Unlimited - Due to: Unlimited
| 3 views
0 like 0 dislike
11 answers
[Exam] asked Apr 21, 2017 in Midterm
Available when: Unlimited - Due to: Unlimited
| 3 views
8,033 questions
60,929 answers
33,033 comments
1,102 users