Answer to Question #184173 in C++ for Skye Jordan

Question #184173

Based on the question below, write a program using :

a. For loop

b. While loop

c. Do..while loop


A class of ten students took a quiz. The mark is between the ranges 0 - 25 for this quiz is available to you. Determine the average mark for this quiz. Based on this problem, you are required to create a program. 



1
Expert's answer
2021-04-22T04:51:26-0400


#include <iostream>
#include <string>
using namespace std;






int main()
{  
	int studentsQuiz[10];
	int i=0;
	//a. For loop
	for(i=0;i<10;i++){
		studentsQuiz[i]=-1;
		while(studentsQuiz[i]<0 || studentsQuiz[i]>25){
			cout<<"Enter the mark between the ranges 0 - 25 for this quiz "<<(i+1)<<": ";
			cin>>studentsQuiz[i];
		}
	}
	//b. While loop
	//Determine the average mark for this quiz.
	i=0;
	float sum=0;
	float average;
	while(i!=10){
		sum+=studentsQuiz[i];
		i++;
	}
	average=sum/10.0;
	i=0;
	cout<<"\nAll marks:\n";
	//c. Do..while loop
	do{
		cout<<"The mark for the student "<<(i+1)<<" is: "<<studentsQuiz[i]<<"\n";
		i++;
	}while(i!=10);


	cout<<"The average mark for this quiz "<<average<<"\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
APPROVED BY CLIENTS