Tell me, please, how to re-run the algorithms without running the program (do you want to start again? (Y / n)). On the example of the simplest program "Hello, world".

#include <iostream> int main() { std::cout<<"Hello, world!\n"; } 
  • 2
    Once upon a time, people came up with cycles for this - DreamChild
  • can you give an example? - siner
  • @siner open any book on C ++ - DreamChild
  • @siner: indeed, you would read a book. Spoiler: you can scroll directly to the while (although I would recommend to read everything). - VladD

1 answer 1

There are two ways:

  1. is to put all the program code in a while . And add a boolean variable to check (whether to repeat the program).

  2. The main function starts a function in which there will be the main program code, at the end of this function there will be an if that will start the function again with the main program code (this path is not optimal for numerous repetitions).