So I'm really new to programming, but I'm trying to practice all the time, this is one of my "tests", so a lot of my friends told me that using goto is not advised, so what would be some better ways to code this? Thank you in advance <3
cout << "Hello, " << user << " !\n";
START:
cout << "I am familiar with these search engines:\n";
cout << " 1.Google 2.Yandex 3.Bing\n";
cout << " 4.DuckDuckGo 5.StartPage\n";
cout << "Please input what search engine interests you (1-5): ";
cin >> ngin;
//Google part.
if (ngin == 1) {
//What loop (Google)
GOOGLE:
cout << " What would you like to do?\n";
cout << " 1. Information about Google 2. Set Google as default search engine\n";
cout << " 3.Go back.\n";
cin >> what1;
switch (what1) {
case 1:
cout << "Info\n";
goto END;
case 2:
cout << "Google has been set as your default search engine\n";
goto END;
case 3:
goto START;
default:
cout << "Please input either number 1 or 2.\n";
goto GOOGLE;
}
}
else {
cout << "Incorrect input. Try again.";
goto START;
}
//End loop, if case number 2 is chosen the program stops.
END:
cout << "Would you like to continue?\n";
cout << "1.Yes 2.No\n";
cin >> cont;
switch (cont) {
default:
cout << "Incorrect input. Use only stated numbers.\n";
goto END;
case 1:
goto START;
case 2:
cout << "See you next time!\n";
break;
}
}