How do I get this block of code to loop conditionally?
do I need to put this if else inside a while loop, do while, or another if else
Code:
#include <iostream>
using namespace std;
int main()
{
int Answer;
char CreditCardNumber[40];
//I dont know if I should start with do, while, if, or what********
do
{
cout<<"if your ready to enter credit card number: "<<endl;
cout<<"(Enter: [1 for yes]- [2 for no])";
cin>>Answer;
cin.sync();
cin.get ();
if (Answer==1)
{
cout<<"ready to process transaction";
cout<<"please enter credit card number";
cin>>CreditCardNumber;
cin.sync();
cin.get();
}
//this is where my condition to start all over is*******
while (Answer==1)
{
cout<<"would you like another transaction?"<<endl;
cout<<"(Enter [1 for yes] - [2 for no])";
cin>>Answer;
cin.sync();
cin.get();
// I want it to loop back to the top*******
{
}
return 0;
}
}