Guest User

example

a guest
Sep 5th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. 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.
  2.  
  3. int Exam[99];  //each individual grade
  4. int students;  //number of students
  5. int A=0;  // number of students with A's, B's and so forth
  6. int B=0;
  7. int C=0;
  8. int D=0;
  9. int F=0;
  10.  
  11.  
  12. int main(){
  13.     cout "how many students in the class (less than 100)";
  14.     cin >> students
  15.  
  16.     if(students>100)
  17.         cout "reject";  //make sure you handle invalid user inputs this isn't complete
  18.    
  19.     cout "enter your marks";
  20.     for(i=0,i<students;i++){
  21.         cout << "mark? " << "(" cout i+1 << cout " student)"
  22.         cin >> Exam[i]
  23.         if(grade is a)
  24.             A++
  25.         if(grade is b)
  26.             B++
  27.  
  28.         if(grade is c)
  29.             C++
  30.  
  31.         if(grade is d)
  32.             D++
  33.  
  34.         if(grade is f)
  35.             F++
  36.  
  37.  
  38.     }
  39.  
  40.     cout "display a b c d e f" cout A << count << B
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment