i don't think the whole program can be rerunned with new code. once you added a new piece to your program you have to recompile your cpp file to let the program work again. since u can only compile it when your program isn't running this looks quite impossible to do so.
#include <iostream>
usingnamespace std;
int main()
{
bool restart = false;
char input;
while (restart==false)
{
//your code
cout << would you like to restart? y/n? << endl;
cin >> input;
if(input=='n')
restart = true; //ends the while statement because statement only runs when restart is true
else
restart = false;
}//while loop
}// main function
#include <iostream>
usingnamespace std;
int main()
{
char input;
beginning: //make sure to put the colon after and this statement should not be indented.
//your code
cout << would you like to restart? y/n? << endl;
cin >> input;
if(input=='y')
goto beginning;
elsereturn 0;
}// main function
#include <iostream>
usingnamespace std;
int main()
{
char choice;
while(true)
{
// Stuff
cout << "Are you finished? y/n: ";
cin >> choice;
if(choice == 'y'){
break; // will exit the loop.
} else {
continue; // will immediately go to the start of the loop.
}
// Code here wouldn't be run because of continue.
}
cout << "You broke out of the loop. Ending Program.";
}