Write a program that accepts grade as input from the user and stores these grades in twodimensional array with dimension of 5 rows and by 5 columns. Then count the number of grades that
passed and the number of grades that failed. Grade that pass must be greater or to equal to 80.
Enter the grades: 90 95 78 89 88 71 72 79 81 82 77 74 78 88 91 73 77 75 84 98 76 89 71 87 73 79
There are 12 that passed.
There are 13 that failed.
#include<iostream>
using namespace std;
int main()
{
int arr[5][5];
int passed=0;
int failed=0;
cout<<"Enter the grades: ";
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
cin>>arr[i][j];
if(arr[i][j]>=80)passed++;
else failed++;
}
}
cout<<"\nThere are "<<passed<<" that passed.";
cout<<"\nThere are "<<failed<<" that failed.";
}
Comments
Leave a comment