A special site for solving fun programming problems and challenges, interested in computer science, programming, basics, data structure and algorithms

 Given a letter X. Determine whether X is Digit or Alphabet and if it is Alphabet determine if it is Capital Case or Small Case.

Note:

  • Digits in ASCII '0' = 48,'1' = 49 ....etc
  • Capital letters in ASCII 'A' = 65, 'B' = 66 ....etc
  • Small letters in ASCII 'a' = 97,'b' = 98 ....etc
Input

Only one line containing a character X which will be a capital or small letter or digit.

Output

Print a single line contains "IS DIGIT" if X is digit otherwise, print "ALPHA" in the first line followed by a new line that contains "IS CAPITAL" if X is a capital letter and "IS SMALL" if X is a small letter.

Examples
input
Copy
A
output
Copy
ALPHA
IS CAPITAL
input
Copy
9
output
Copy
IS DIGIT
input
Copy
a
output
Copy
ALPHA
IS SMALL
Note

** recommended to read this to know more about ASCII Code https://www.javatpoint.com/ascii.


my code:

#include<iostream>

using namespace std;


int main()

{

char ch;

cin >> ch;

if (ch >= 65 && ch <= 90)

{

cout << "ALPHA\n";

cout << "IS CAPITAL\n";

}

else if (ch >= 97 && ch <= 122)

{

cout << "ALPHA\n";

cout << "IS SMALL\n";

}

else

{

cout << "IS DIGIT\n";

}


return 0;

}


No comments:

Post a Comment