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.
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;
}
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;
}
0
each character has its ASCII code so u can write a. >b