djnaf
03-10-04, 05:52 PM
i'm writing a c++ program
that takes an information on N students (N<=100)
Calculates the average of each one: the weight of the different exams are ( First Exam 25%, seconf exam 25%, final exam 50%)
find the name of the student wo received the best average
calculate the average of teh class
i must use a structer called STUDENT with 4 fields.
i'll paste what i've written unil now, the program is not fully done
so i need ut help in it plz. tell me what i forgot to add.
and i want u to help me how to add two fuctions:
-A function Find_Max with two parameters: an array of struct student and an integer representing the number of the students in the class.
-A function Find_Average with two parameters an array of struct student and an integer representing the number of students in the class.
-A function Display_Class with two parameters: a pointer to the first item in an array of struct student and an integet representing the number of students in the class.
=======================================
#include<iostream.h>
struct student
{
int number;
char name[10];
float grades[3];
float avg;
};
void main()
{
int n;
cout<<"enter the number of students: ";
cin>> n;
}
void Get_Student(student *s)
{
cout<<"Name: ";
cin>> s->name;
cout<<"Number: ";
cin>> s->number;
cout<<"First Grade: ";
cin>> s->grades[0];
cout<<"Second Grade: ";
cin>> s->grades[1];
cout<<"Final Grade: ";
cin>> s->grades[2];
}
void Get_Class(student s[], int n)
{
int i;
for (i=0;i<n;i++)
{
Get_Student(&s[i]);
}
}
void Display_Student(student s[], int i)
{
cout<<"student no:"<<s[i].number<< endl;
cout<<"student name:"<<s[i].name << endl;
cout<<"student 1st grade:"<<s[i].grades[0] << endl;
cout<<"student 2nd grade:"<<s[i].grades[1] << endl;
cout<<"student 3rd grade:"<<s[i].grades[2] << endl;
cout<<"the avrege for student:"<<s[i].avg << endl;
}
void Display_Class(student *s, int n) /* i think this function is wrong*/
{
for(int i=0;i<n;i++){
Display_Student(&s[i]);
}
}
that takes an information on N students (N<=100)
Calculates the average of each one: the weight of the different exams are ( First Exam 25%, seconf exam 25%, final exam 50%)
find the name of the student wo received the best average
calculate the average of teh class
i must use a structer called STUDENT with 4 fields.
i'll paste what i've written unil now, the program is not fully done
so i need ut help in it plz. tell me what i forgot to add.
and i want u to help me how to add two fuctions:
-A function Find_Max with two parameters: an array of struct student and an integer representing the number of the students in the class.
-A function Find_Average with two parameters an array of struct student and an integer representing the number of students in the class.
-A function Display_Class with two parameters: a pointer to the first item in an array of struct student and an integet representing the number of students in the class.
=======================================
#include<iostream.h>
struct student
{
int number;
char name[10];
float grades[3];
float avg;
};
void main()
{
int n;
cout<<"enter the number of students: ";
cin>> n;
}
void Get_Student(student *s)
{
cout<<"Name: ";
cin>> s->name;
cout<<"Number: ";
cin>> s->number;
cout<<"First Grade: ";
cin>> s->grades[0];
cout<<"Second Grade: ";
cin>> s->grades[1];
cout<<"Final Grade: ";
cin>> s->grades[2];
}
void Get_Class(student s[], int n)
{
int i;
for (i=0;i<n;i++)
{
Get_Student(&s[i]);
}
}
void Display_Student(student s[], int i)
{
cout<<"student no:"<<s[i].number<< endl;
cout<<"student name:"<<s[i].name << endl;
cout<<"student 1st grade:"<<s[i].grades[0] << endl;
cout<<"student 2nd grade:"<<s[i].grades[1] << endl;
cout<<"student 3rd grade:"<<s[i].grades[2] << endl;
cout<<"the avrege for student:"<<s[i].avg << endl;
}
void Display_Class(student *s, int n) /* i think this function is wrong*/
{
for(int i=0;i<n;i++){
Display_Student(&s[i]);
}
}