0

how to write a program that reads in a character <char> from the keyboard and then displays one of the following messages 1. if<char> is in lowercase letter the message "the uppercase letter corresponding to char is..." 2. if<char> is in uppercase letter the message "the lowercase letter corresponding to char is..." 3. of char is not a letter, the message char is not a letter.

9th Sep 2016, 6:49 PM
Prakhar
Prakhar - avatar
3 odpowiedzi
+ 5
http://code.sololearn.com/cLnoqd1pN3Wp #include <iostream> using namespace std; int main() { char c; cout << "Please enter a character" << endl; cin >> c; if ((c >= 'a')&&(c <= 'z')) { cout << "The uppercase letter corresponding to " << c << " is " << char(c - 26 - ('a'-'Z'-1))<< endl; } else if ((c >= 'A')&&(c <= 'Z')) { cout << "The lowercase letter corresponding to " << c << " is " << char(c + 26 + ('a'-'Z'-1))<< endl; } else { cout << c << " is not a letter."; } return 0; }
9th Sep 2016, 7:21 PM
Zen
Zen - avatar
0
#include <iostream> using namespace std; int main() { char s; cout << "Enter a letter\t: "; cin >> s; if ((s < 65 || s > 90) || (s < 97 || s > 122)) cout << "Its not a letter"; else if (s > 64 && s < 91) cout << "It's in upper case"; else if (s > 96 && s < 123) cout << "It's in lower case"; return 0; }
9th Sep 2016, 7:27 PM
Chinmay Majumdar
Chinmay Majumdar - avatar
0
each character has its ASCII code so u can write a. >b
10th Sep 2016, 3:12 AM
Kush Gupta
Kush Gupta - avatar