Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int grades[50][10], s, c;
- cout << "Number of students: "<<endl;
- cin >> s;
- cout << "Number of classes the students took: "<<endl;
- cin >> c;
- for (int i = 0; i < s;i++) { //loop for entering grades
- cout << "Enter the grades for student "<<i+1<<": "<<endl;
- for (int j = 0; j < c;j++) {
- cin >> grades[i][j];
- }
- }
- for (int i = 0; i < s;i++) { //loop for displaying grades
- float sum = 0.0;
- int counter=0;
- for (int j = 0; j < c;j++) {
- if (grades[i][j] == 2) {
- counter++;
- }
- else {
- sum = sum + grades[i][j];
- }
- }
- if (counter>0) {
- cout << "Student "<<i+1<<" has failled "<<counter<<" classes!"<<endl;
- }
- else {
- cout << "Student " << i + 1 <<" has an average of "<<sum/c<<"." << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement