#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.
#include <iostream>
usingnamespace 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' )
elseif ( 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" ;
}