could someone plz help me

How could you loop the program so that it prompt the user by display for the different
score 3
score 2
score 1
as now i only able to display one how cud i use a loop to display change in score prompt

#include <iostream>
using namespace std;

int main()
{
double scores;
double sum=0;
double avg=0;

cout << "Enter three scores: ";
for(int i=1; i<=3; i++)
{
cin >> scores;

if(scores>0 && scores<=100)
sum=sum+scores;

else
{ cout << "Invalid Input." << endl;
system ("pause"); }
}

avg=sum/3;

cout << "Average is: " << avg << endl;

system ("pause")
Hello hollup,

I think what you are asking for would be to add a line in the for loop before the cin something like:
std::cout << "Enter score " << i << " :";.

I am also thinking the last statement of the else statement should be i--; so when you return to the for statement it will add 1 before it checks the condition to see if it's finished. A Thought, I have not tested it yet.

Hope that helps,

Andy

P.S. Tested. The i--; does work correctly.
Last edited on
yeah i tried it works tankz a million handy andy
Topic archived. No new replies allowed.