I learned to program in BASIC, and have just started useing C++. Having a little trouble with the syntax.
I am writing a basic program that averages numbers. In the first part, the user inputs a whole number greater than 1, which is stored as the "number" variable. Then...
int array(number);
{
cout<<"\nEnter a number: ";
cin>> //What do I put here?
I want the user to enter any number, and have it stored as the first slot (x) in the array, then have another line that increases the value of x by one, checks to see if it equals "number," and loop back around if it doesn't.
Something like this, but I don't know the correct syntax:
int array(number);
x=1
{
cout<<"\nEnter a number: ";
cin>> array(x)
If (x==number)
{
goto the rest of the program
Else
{
goto the start and let the user input another number.
}
I heard that using goto statements wasn't good programming, and that there were other ways of doing it. What are these ways?
Thx!