Hello I am trying to write a code to answer a yes or no question. If yes go to next task and if no go back to the beginning. But what I have is this, it will keep going to the next task no mater what I pick. Any help is greatly appreciated.
#include <iostream>
usingnamespace std;
int main()
{
//intitialize variable
char answer = 'n';
//while loop to continue till they are satisfied with their input
while (answer == 'n' || answer == 'N')
{
//do something
cout << "Do something here" << endl;
//ask if it was right
cout << "Is that right(y/n)?" << endl;
//user input
cin >> answer;
//if statmen to output wether they are going to continue or not
if (answer == 'y' || answer == 'Y')
{
cout << "We will contiue then" << endl;
}
else
{
cout << "Ok, we'll try again" << endl;
}
}
return 0;
}