0
In c++ how do i build up variables for 1 letter and then when i have that letter as input it should pick one of the variables
3 Réponses
0
the char variable is suitable for this. For example, like this:
int main()
{
char i = 'o';
char p = 'h';
int x;
cout << "select letter" << endl;
if (x == 1)
{
cout << "letter = " << i << endl;
}
if(x == 2)
{
cout << "letter = " << p << endl;
}
return 0;
}
0
So what would i input here
0
In this case, you must enter a variable to select one of the letters. I can offer another option:
int main()
{
int x = // your number
int y = // your number;
char i;
cin >> i;
if (your logics)
{
cout << x << endl;
}
if (your logics)
{
cout << y << endl
}
else
{
cout << "wrong input" << endl;
}
return 0;
}
here the letter is entered that the user entered, and according to the logic conceived, one of the conditions is met.