Hi I'm new here:)

What's wrong with my codes? :(

#include <iostream>
using namespace std;
int main()
{
char let;
char d;

cout<<"What do you want? Letter or Number"<<endl;
cout<<"If you want a letter press just choose from a,b,c,d,e"<<endl;
cout<<"If you want a number press just choose from 1,2,3,4,5"<<endl;
cin>>d;

if (d == 'a' || 'b'|| 'c' || 'd' || 'e')
{
cout<<"So you want letter.."<<endl;
{
if ((let=='a') || (let=='e'))
cout<<"vowel";
else if (let != 'a' || 'e')
cout<<"consonant";
}
}
else if (d == '1' || '2'|| '3' || '4' || '5')
{
cout<<"So you want number.."<<endl;
}
}



it only shows:

What do you want? Letter or Number
If you want a letter press just choose from a,b,c,d,e
If you want a number press just choose from 1,2,3,4,5
1
So you want letter..
consonant




I'm trying to make a Nested If-Statement, but I failed. What I want to happen is, when I type a,b,c,d or e it must print " so you want letter.." and then identify if it is a vowel or consonant. Otherwise, if I type 1,2,3,4 or 5 it must print "so you want number.." and then show the number i typed.

I'm sorry if my explanation is kinda confusing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;

int main()
{
    //char let;
    char d;

    cout << "What do you want? Letter or Number" << endl;
    cout << "If you want a letter press just choose from a,b,c,d,e" << endl;
    cout << "If you want a number press just choose from 1,2,3,4,5" << endl;
    cin >> d;

    // if ( d == 'a' || 'b' || 'c' || 'd' || 'e' )
    if ( d == 'a' || d == 'b' || d == 'c' || d == 'd' || d == 'e' )
    {
        cout << "So you want letter.." << endl;
        {
            //if ( let == 'a' ) || ( let == 'e' ) )
            if( ( d == 'a' ) || ( d == 'e' ) )
                cout << "vowel";
            else // if ( let != 'a' || 'e' )
                cout << "consonant";
        }
    }
    //else if ( d == '1' || '2' || '3' || '4' || '5' )
    else if ( d == '1' || d == '2' || d == '3' || d == '4' || d == '5' )
    {
        cout << "So you want number.." << endl;
        cout << "the number is: " << d << '\n' ;
    }

    else cout << "invalid input\n" ;
}
Thank you so much Sir! :D
Topic archived. No new replies allowed.