Answer to Question #203754 in C++ for she

Question #203754

a) Write a program to count the number of female and male students in class of 30. User need to input gender for each student.


b) Write a program to count the number of students who gets more than 5 marks of quizzes in class 30. User need to input mark of quiz for each student.


c) Write a program to find the highest and lowest of quiz mark of 30 students. User need to input mark of quiz for each student.


1
Expert's answer
2021-06-05T23:57:46-0400
#include <iostream>


using namespace std;


//The start point of the program
int main(){
	int totalFemale=0;
	int totalMale=0;
	for(int s=0;s<30;s++){
		int gender=-1;
		//input gender for each student.
		while(gender<1 || gender>2){
			cout<<"Select gender for student "<<(s+1)<<" (1 - female, 2 - male): ";
			cin>>gender;
		}
		if(gender==1){
			totalFemale++;	
		}else{
			totalMale++;
		}
	}
	//display result
	cout<<"The number of female students in class of 30: "<<totalFemale<<"\n";
	cout<<"The number of male students in class of 30: "<<totalMale<<"\n\n\n";

	system("pause");
	return 0;
}




#include <iostream>


using namespace std;


//The start point of the program
int main(){
	int numberStudentsGetsMore5Marks=0;
	for(int s=0;s<30;s++){
		int markQuiz=-1;
		cout<<"Enter mark of quiz for student "<<(s+1)<<": ";
		cin>>markQuiz;
		if(markQuiz>5){
			numberStudentsGetsMore5Marks++;	
		}
	}
	//display result
	cout<<"The number of students who gets more than 5 marks of quizzes in class 30: "<<numberStudentsGetsMore5Marks<<"\n\n";




	system("pause");
	return 0;
}



#include <iostream>


using namespace std;


//The start point of the program
int main(){
	int highestQuizMark=-100;
	int lowestQuizMark=100;
	for(int s=0;s<30;s++){
		int markQuiz=-1;
		//input mark of quiz for each student.
		cout<<"Enter mark of quiz for student "<<(s+1)<<": ";
		cin>>markQuiz;
		//find the highest and lowest of quiz mark of 30 students. 
		if(markQuiz>highestQuizMark){
			highestQuizMark=markQuiz;
		}
		if(markQuiz<lowestQuizMark){
			lowestQuizMark=markQuiz;
		}
	}
	//display result
	cout<<"The highest of quiz mark of 30 students: "<<highestQuizMark<<"\n";
	cout<<"The lowest of quiz mark of 30 students: "<<lowestQuizMark<<"\n\n";




	system("pause");
	return 0;
}




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