how to get a program to go to the start

Hi i am very stuck, i have a question is there any way to tell the computer to go back to start of the program when using while loops? would also like to know how to tell the program to go to a specific part of a while loop?

 
 
You mean like:
1
2
3
4
5
6
7
8
while(std::cin >> input) {
    input *= input;
    
    if (input > 100) //If resulting value is to hight start over
        //...

    std::cout << 100 / input;
}
In these cases you probably want to look into continue and break as additional loop controls.
http://en.cppreference.com/w/cpp/language/continue
http://en.cppreference.com/w/cpp/language/break
However I would advise to redesign your program structure so these additional control flow statements won't be nessesary


Here is my full question;
http://www.cplusplus.com/forum/beginner/112548/


i need to get to the beginning of the program after the end of part3, what am i doing wrong?
1) Break your program into functions. Your main() function is way larger than it should be. Also this will make program easier to read and maintain.

2) You probably want to wrap your program in another loop which will return player back to the beginning:
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
//
    bool runGame = true;
    while(runGame) {
        //getting input

        //Game

        //ask if want to play again
    }
//
} 
1. how do you mean, can you give ex?
2.sounds like good idea

3. Still though would you be able to tell me why my statement part1=true is not taking me to that loop? it doesn't take me anywhere after the end of part3 im stuck??
Here I separated game itself from lobby where you asked if you want ot play a game or if you want to play again:
http://pastebin.com/cPJKsDK3
part1, part2 and part 3 are good to break into their own functions.

Also after formatting I have found several logic errors: look at lines 27 and 96: program aroun those places might work not like you want.
Topic archived. No new replies allowed.