I'm a beginner in coding in C++. I just came to ask on how to loop your program.
Like for e.g, in my practice program.
I want the program to loop, right here.
and right here, i want to be able to press 2 and have the program close.
Like for e.g, in my practice program.
Code:
using namespace std;
int main()
{
cout << "One = Yes Two = No \n";
float num1;
float num2;
int number;
num1 = 1;
num2 = 2;
cout << "\n Yes or No?\n"<< endl;
cin >> number;
if (number == 1)
{
cout << "You have chosen 1.\n "<< endl;
cout << " Restart program? \n Yes or No?";
cin >> number;
if(number==1)
{
//
}
else
{
// Just testing this.
system("PLAY")
}
}
else
{
if(number == 2)
{
cout << "You have chosen 2. \n"<< endl;
}
else
{
cout << "You didn't follow the proper instructions.\n"<< endl;
}
}
system("PAUSE");
return 0;
}
Code:
cout << "You have chosen 1.\n "<< endl;
cout << " Restart program? \n Yes or No?";
cin >> number;
if(number==1)
{
//
}
else
{
// Just testing this.
system("PLAY")
}
Code:
else
{
// Just testing this.
system("PLAY")
}