It's my first time posting here, so I apologize if the post is not formatted correctly. I'm new to C++ and was looking for some help.
I can't seem to figure out what is stopping my code after roughly the 18th line. It processes the first cout and cin, but dosen't continue with the next cout?
If you enter a key, it will run through all of the conditions listed in the if/then statement and finish. However, my goal for what is here, is to have the computer generate a random number, followed by asking me for input (Y/N). Given the input, it's either supposed to generate another random number or end.
Using the compiler generate no errors, so I'm a bit dumbfounded right now as to what the issue is.
I'd appreciate any help, thank you.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<iostream.h>
int comp;
using namespace std;
int main ()
{
comp= 1+(rand() % 10);
randomnumber:
string again;
cout <<"The computer chose this random number: "<< comp << endl;
cin >> comp;
cout << "Would you like to run this again? Y/N" << endl;
cin >> again;
if((again == "y")||(again == "Y"))
{
goto randomnumber;
}
else if((again == "n")||(again == "N"))
{
cout << "OK" << endl;
}
else if((again != "y")||(again != "Y")||(again != "n")||(again !="N"))
{
cout << "Please type Y or N" << endl;
}
return 0;
}