Switch case | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Switch case

How to create a program that will accept character from A to E and identify if the character is -small letter or capital letter -is it is the 1st letter, 2nd letter, 3rd letter, 4th letter, 5th letter of the aphabet

5th Nov 2020, 2:49 AM
Unknown
4 Answers
0
https://code.sololearn.com/chJ1eAorSPzO/?ref=app Hi, you can check my code. I've done a little
5th Nov 2020, 3:24 AM
Azalea
+ 6
Take a character as input. cin >> ch Then put it in switch switch(ch) Match the cases case A: cout << "capital" << "1st Letter" ; break;
5th Nov 2020, 2:53 AM
ツSampriya😘ツ
ツSampriya😘ツ - avatar
+ 1
Here is a one-liner that does it all, presuming the input is correct: cout << ch << ((ch&32) ? " is lowercase" : " is uppercase") << " and is letter number " << ((ch|32) - 'a' + 1) << "." << endl;
5th Nov 2020, 9:05 AM
Brian
Brian - avatar
5th Nov 2020, 2:56 AM
Unknown