Question #1343

Write a c++ program that reads 5 student names and grades then prints the number of pass and fail students . Remarks : Passing grade is 60?

Expert's answer

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char** argv)
{
& string* names = new string[5];
& int* grades = new int[5];
& int passed = 0; // number of pass students

& cout << "Please input names of 5 students(Ex: Name Grade):" << endl;
& for(int i = 0; i < 5; i++)
& {
cin >> *(names + i);
cin >> *(grades + i);
& }
& for(int i = 0; i < 5; i++)
& {
if(*(grades + i) >= 60)
{
passed++;
}
& }
& cout << "Number of pass students: " << passed << endl;
& cout << "Fail: " << 5 - passed << endl;


& delete[] names;
& delete[] grades;

& return 0;
}

LATEST TUTORIALS
APPROVED BY CLIENTS