Having Issues with Initializing Char

I'm making a program and at the very start it prompts the user to choose to know the answer to one of three options.



cout << "This computer program calculates and prints the diameter, the circumference, or the area of a circle, given the radius." <<endl;
cout << "Please enter D (diameter), C (circumference), or A (area): " <<endl;



now my problem is I can't successfully get my program to continue beyond this. The input has to be D, C, or A. If it isn't. it will prompt the user again:


cout << "Incorrect input." <<endl;
cout << "Please enter D (diameter), C (circumference), or A (area): " <<endl;
cin >> input;


What kind of while-loop (or function, I am becoming versed in those) do I use to seperate the two (incorrect and correct input)?

Furthermore, what function or while-loop do I use to successfully seperate the correct choices? When I compile, it says the D, C, and A need to be initialized, but to what? I just need the user to put one of the three in to continue the program. I don't want to assign them to anything! So I tried this:



char diameter = 'D';
char circumference = 'C';
char area = 'A';


and used a while-loop suggesting that if it wasn't those three, to say it was incorrect and move on, but even if the user enters D, C, or A, it still says its incorrect!


while (input != diameter || input != circumference || input != area)
{
cout << "Incorrect input." <<endl;
cout << "Please enter D (diameter), C (circumference), or A (area): " <<endl;
cin >> input;

}

If someone could shed some light on my ordeal, that would be awesome.
while (input != diameter || input != circumference || input != area)
Change the ors to ands
Topic archived. No new replies allowed.