Implementations of Structures

I don't understand why my code is not compiling

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  /*
Using the program you developed for Homework 1, define a structure which supports the following types of information:
-  student name
-  student ID number
-  current exam grade
-  prior exam grade
-  overall GPA
The user will once again identify the number of students being represented and will then provide the 5 pieces of information for each student.
The user can sort based on any one of the 5 criteria, by specifying a value of 1-5.  
After sorting, print the result. 
*/
#include <iostream>
#include <cmath>
#include <algorithm> //contains sort
#include <string>
#include <iomanip>
using namespace std; 

//define a structure which supports the following types of information
//-  student name
//-  student ID number
//-  current exam grade
//-  prior exam grade
//-  overall GPA
struct student;
{
string student_name;
int student_ID,current_grade,prior_grade;
double overall_GPA;
}


//global variables
int grade[30],size1;

//get grades, and then sort them
//should probably separate these functions
void accept_sort_grade(student data[])
{
int i;
for(i=0;i<size1;i++)
{
	//provide the 5 pieces of information for each student
	//-  student name
cout<<"Enter the student's name for student #"<<i<<endl;
cin>> data[i].student_name;
	//-  student ID number
cout<<"Enter the student's ID number#"<<i<<endl;
cin>> data[i].student_ID;
	//-  current exam grade
cout<<"Enter the current grade #"<<i<<":"<<endl;
cin>> data[i].current_grade;
	//-  prior exam grade
cout<<"Enter the prior grade #"<<i<<":"<<endl;
cin>>data[i].prior_grade;	
	//-  overall GPA
	cout<<"Enter the ovrall GPA #"<<i<<":"<<endl;
cin>>data[i].overall_GPA;
}
//The user can sort based on any one of the 5 criteria, by specifying a value of 1-5.
//get user input
sort(&grade[0],&grade[size1]); //use array sort
return;                    
}

int main ()
{
int sum1=0; //store grade total
double av1; //store grade average

//identify the number of students being represented
do 
{
cout<<"Enter the number of grades."<<endl;
cin>>size1;
}
while((size1>30) || (size1<=0)); //get a number 1-30

accept_sort_grade();

//After sorting, print the result. 
cout<<"The sorted grades are: "; 
for(int i=0;i<size1;i++)
{
cout<<grade[i]<<" ";
sum1+=grade[i];
}

av1=(double)sum1/(double)size1; //double = int/int;

cout<<fixed<<setprecision(2); //sets the output to show decimal
cout<<endl<<"The grade average is:"<<av1<<endl;
system ("pause");
return 0;
}
Line 25: The ; is in the wrong place. Move the ; from line 25 to line 30.

Line 79: accept_sort_grade() requires an array of students. You not passing anything.

When posting about compiler errors, please post the exact text of the errors.


Topic archived. No new replies allowed.