"Favorite food" program This is my first program written in C++.  I chose to make this public in order to receive suggestions on further improvements and to know if I'm using any "forbidden" code.

I'm asking because I initially put a lot of gotos in the program, but later found out that using goto was "evil."  Therefore, after a lot of trial and error, I removed them all and replaced them with a couple of do-while loops. I must say using do-while makes the final code much easier to read.

Please let me know if you still see any "forbidden" code.

#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main () {

    string name, favfood, age, y_n_decision;

    do {

        cout &lt;&lt; "welcome to my program in c++" &lt;&lt; endl;
        cout &lt;&lt; "Please enter your name" &lt;&lt; endl;
        getline (cin, name);

        cout &lt;&lt; "enter your favourite food" &lt;&lt; endl;
        getline (cin, favfood);
        cout &lt;&lt; "awesome! " &lt;&lt; favfood &lt;&lt; " is my favourite food too" &lt;&lt; endl;

        cout &lt;&lt; "enter your age" &lt;&lt; endl;
        getline (cin, age);

        cout &lt;&lt; " so your name is " &lt;&lt; name &lt;&lt; " and your fav food is " 
        &lt;&lt; favfood &lt;&lt; " and your age is " &lt;&lt; age &lt;&lt; endl;

        cout &lt;&lt; "please press Y to restart, or Q to quit" &lt;&lt; endl;

        do {

            getline (cin, y_n_decision);

            if (y_n_decision == "q") {
                cout &lt;&lt; "quitting now" &lt;&lt; endl;
                return 0;
            }

            else if (y_n_decision == "y") {
                cout &lt;&lt; "nice! you typed y. Exiting current loop and returning to int main() aka the beginning." &lt;&lt; endl;
                break;
            }

            else {
                cout &lt;&lt; "you didn't type either y or q. YOU MUST PRESS Y OR Q OR I WILL PROMPT U FOREVER!!" &lt;&lt; endl;
            }

        } while (y_n_decision == "y" || "n");

    } while (y_n_decision == "y" || "n");

    return 0;
}


EDITED:

#include &lt;iostream&gt;
#include &lt;string&gt;

using std::cout;
using std::endl;
using std::string;
using std::cin;


int main () {

    string name, favfood, age; 
    string y_n_decision;

    while (y_n_decision != "y" || y_n_decision != "q") {
        cout &lt;&lt; "welcome to my program in c++" &lt;&lt; endl;
        cout &lt;&lt; "Please enter your name" &lt;&lt; endl;
        getline (cin, name);

        cout &lt;&lt; "enter your favourite food" &lt;&lt; endl;
        getline (cin, favfood);
        cout &lt;&lt; "awesome! " &lt;&lt; favfood &lt;&lt; " is my favourite food too" &lt;&lt; endl;

        cout &lt;&lt; "enter your age" &lt;&lt; endl;
        getline (cin, age);

        cout &lt;&lt; " so your name is " &lt;&lt; name &lt;&lt; " and your fav food is " 
        &lt;&lt; favfood &lt;&lt; " and your age is " &lt;&lt; age &lt;&lt; endl;

        cout &lt;&lt; "please press y to restart, or q to quit" &lt;&lt; endl;

        while (y_n_decision != "y" || y_n_decision != "q") {

            getline (cin, y_n_decision);


            if (y_n_decision == "q") {
                cout &lt;&lt; "quitting now" &lt;&lt; endl;
                return 0;
            }

            else if (y_n_decision == "y") {
                cout &lt;&lt; "nice! you typed y. Exiting current loop and returning to int main() aka the beginning." &lt;&lt; endl;
                break;
            }

            else { 
                cout &lt;&lt; "you didn't type either y or q. YOU MUST PRESS y OR q OR I WILL PROMPT U FOREVER!!" &lt;&lt; endl;
            }
        } 

    }
    return 0;
}
Armond, the main thing you should do is to learn about functions.  Putting everything in main is not practicable beyond very small programs.   And nested loops are generally a bad idea too.  So for example you might extract the content of the first loop into a function and extract the second loop into another function.

So you would get something like:

int main(int argc, char **argv)
{
    do {
        user_interaction();
    } while (user_says_exit() == false);
    return 0;
}


Also note that while (true) {...} is more commonly used than do {... } while (true); although do{} while() loops clearly have their uses.


EDIT

To be honest, I like the edited version less than the original.  You are now testing the y_n_decision as the condition in both loops. And you are relying on the variable having been default-initialized. Moreover the loops are now while instead of do-while and are arguably more wrong now than they were before.  A while (true) loop is preferable to your original do ... while (true)  because the condition (true) is immediately visible at the top of the loop.  But the new loops using while (condition) rely upon the initial value of the condition - and in your case you have to force that to be false by using an initializer that is not y/q. This is at best inelegant.

Here is how I might have coded what you are doing:

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;ctype.h&gt;

using std::cout;
using std::cin;
using std::endl;

static bool user_says_exit(void)
{
    std::string decision;
    do {
        cout &lt;&lt; "Please press y to restart, or q to quit" &lt;&lt; endl;
        getline(cin, decision);
    } while (decision != "y" &amp;&amp; decision != "q");
    return (decision != "y");
}

static void user_interaction(void)
{
    std::string age;
    std::string favfood;
    std::string name;
    cout &lt;&lt; "Welcome to my program in c++" &lt;&lt; endl;
    cout &lt;&lt; "Please enter your name" &lt;&lt; endl;
    getline (cin, name);
    cout &lt;&lt; "Enter your favourite food" &lt;&lt; endl;
    getline (cin, favfood);
    cout &lt;&lt; "Awesome! " &lt;&lt; favfood &lt;&lt; " is my favourite food too" &lt;&lt; endl;
    cout &lt;&lt; "Enter your age" &lt;&lt; endl;
    getline (cin, age);
    cout &lt;&lt; "So your name is " &lt;&lt; name &lt;&lt; ", your fav food is "
         &lt;&lt; favfood &lt;&lt; " and your age is " &lt;&lt; age &lt;&lt; endl;
}

int main(int argc, char **argv)
{
    do {
        user_interaction();
    } while (user_says_exit() == false);
    cout &lt;&lt; "Quitting now" &lt;&lt; endl;
    return 0;
}