Using while loop, write a C++ program that will allow the users to enter the number of quizzes to compute and the program will automatically compute the average of the quizzes.
Sample Output:
Output:
Enter Number of Quiz: 4
Quiz 1: 90
Quiz 2: 89
Quiz 3: 94
Quiz 4: 100
Average: 93
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int numberQuiz;
cout<<"Enter Number of Quiz: ";
cin>>numberQuiz;
float sum=0;
float quiz;
int i=0;
while(i<numberQuiz){
cout<<"Quiz "<<(i+1)<<": ";
cin>>quiz;
sum+=quiz;
i++;
}
cout<<"\nAverage: "<<(int)sum/numberQuiz<<"\n\n";
system("pause");
return 0;
}
Comments
Leave a comment