Mostlygoldie
Mostlygoldie

Reputation: 21

asking user for how many numbers they want to add then, using while-loop have the user type in those numbers and find the average

I'm struggling to get the loop to repeat according to the user's input.

//ask users for how many numbers they'd like to add
System.Console.Write("How many numbers would you like to 
add?: ");
int count= Convert.ToInt32(Console.ReadLine());
int userinput= 0; 
int counter=1;


while ( counter >  count ;
{
  System.Console.Write(" please enter you number" +  
  counter + ": ");
  userinput= Convert.ToInt32(Console.ReadLine());

  counter ++;
}

this is what i have so far but i know im nowhere close to right. im a beginner in grade 11 so please be beginner friendly ! thank you

Upvotes: 0

Views: 925

Answers (1)

Kvble
Kvble

Reputation: 294

Welcome! You just need to fix the condition you wrote in the while statement, the correct condition in this situation would be (counter <= count) also you have to be careful with syntax in this line
while ( counter <= count ; which is going to be while(counter <= count) then finally the loop should work as expected. Hope I could help, I'm also new to this platform!

Upvotes: 1

Related Questions