Switch case 'x': case 'X': in simple form

I am trying to figure out How I can Do this in its simplest form.
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
#include <iostream>

using namespace std;
char checkinput(char input)
{
          if (input=='x')return 'x';
          if (input=='X')return 'x';
          if (input=='y')return 'y';
          if (input=='Y')return 'y';
          else return 'd';// d means switch to default
}
void testswitch()
{
          char choice;
          cin>>choice;
          switch(checkinput(choice)){
          case 'x':cout<<"Case x or X"<<endl;break;
          case 'y':cout<<"Case y or Y"<<endl;break;
          default: cout<<" None"<<endl;break;
          }
}


int main()
{
          testswitch();
          return 0;
}

Last edited on
Your tha best. thanks!!
You're welcome :)
Topic archived. No new replies allowed.