C++
Write a program which accepts a character from the user. If the character is between 0 and 9, it will output that it's a digit. If the character is lowercase it will output that its a lowercase character. If it's an uppercase character it will output that it's uppercase. For all other cases it will output that it's neither a digit nor a letter. As an example of the output:
Enter a digit or a letter: A You entered an uppercase character.
#include<iostream> using namespace std; int main() { char ch; cout<<"Enter a digit or a letter: "; cin>>ch; if(ch >='0' && ch <='9'){ cout<<"You entered a digit"<<endl; } else if(ch >='A' && ch <='Z'){ cout<<"You entered an uppercase character."<<endl; } else if(ch >='a' && ch <='z'){ cout<<"You entered an lowercase character."<<endl; } else{ cout<<"You entered neither a digit nor a letter."<<endl; } return 0; }
Get Answers For Free
Most questions answered within 1 hours.