Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a program and declare an array called “Exam” with 100 integers. Hence, ask a lecturer to enter the number of students in a class along with each student’s mark that should be stored in the array (use a variable n to know the number of students). The program should then calculate and display: a) the average (float) and the highest and lowest marks of the class, b) the number of grades A, B, C, D and F, according to the following table.
- int Exam[99]; //each individual grade
- int students; //number of students
- int A=0; // number of students with A's, B's and so forth
- int B=0;
- int C=0;
- int D=0;
- int F=0;
- int main(){
- cout "how many students in the class (less than 100)";
- cin >> students
- if(students>100)
- cout "reject"; //make sure you handle invalid user inputs this isn't complete
- cout "enter your marks";
- for(i=0,i<students;i++){
- cout << "mark? " << "(" cout i+1 << cout " student)"
- cin >> Exam[i]
- if(grade is a)
- A++
- if(grade is b)
- B++
- if(grade is c)
- C++
- if(grade is d)
- D++
- if(grade is f)
- F++
- }
- cout "display a b c d e f" cout A << count << B
- }
Advertisement
Add Comment
Please, Sign In to add comment