Answer to Question #281237 in C++ for haaaa

Question #281237

write a function which takes marks of student out of 100 as input and returns his grade pass/fail. Call this function into main() for 3 students



1
Expert's answer
2021-12-20T10:01:35-0500
#include<iostream>
#include<string>

using namespace std;

struct Student
{
	string name;
	int grade;
	Student(string _name, int _grade):name(_name),grade(_grade){}
};

//Suppose, that passing score is 85
bool PassGrade(int grd)
{
	if (grd >= 85)
		return true;
	else
		return false;
}

int main()
{
	Student arrSt[3] = { {"Jack",70},
						 {"Mary",89},
						 {"Mike",90} };
	cout << "Marks of students:\n";
	for (Student* s = &arrSt[0]; s != &arrSt[3]; s++)
	{
		cout << s->name << " " << s->grade << endl;
	}
	for (Student* s = &arrSt[0]; s != &arrSt[3]; s++)
	{
		if (PassGrade(s->grade))
			cout <<"\n"<<s->name << " passed exam";
		else
			cout << "\n" << s->name << " didn`t pass exam";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog