how to read the input word in if statement

i want to make a program that asks the user if he is old or young and depends on the answer the program will go in a certain route using if else-if.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include <iostream>
using namespace std;
int main()
	{
    int x;
    char young, old;
    cout<<"Are you feeling young or old?\n";
    if(cin>>young)
{ //the rest is going well so i wont write it 
   }
   else if(cin>>old)
{ //the rest }
   else 
{ cout<<"bad boy"}


it seems that whatever i write , the program always go to young and run its code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;
int main()
{
    char feeling;
    cout<<"Are you feeling young or old?\n";
    cin >> feeling ;

    if(feeling == 'y')
    { //the rest is going well so i wont write it 
    }
    else if(feeling == 'o')
    { //the rest }
    else 
    { cout<<"bad boy"}
}
variable names are meaningless to the compiler.
thanks , i program works now :D
Topic archived. No new replies allowed.