-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputOutput.cpp
56 lines (51 loc) · 1.13 KB
/
inputOutput.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*Problem statement
Write a program that takes a character as input and prints 1, 0, or -1 according to the following rules.
1, if the character is an uppercase alphabet (A - Z).
0, if the character is a lowercase alphabet (a - z).
-1, if the character is not an alphabet.
Example:
Input: The character is 'a'.
Output: 0
Explanation: The input character is lowercase, so our answer is 0.
Detailed explanation ( Input/output format, Notes, Images )
Sample Input 1 :
v
Sample Output 1 :
0
Explanation of Sample Input 1:
The input character is lowercase, so our answer is 0.
Sample Input 2 :
V
Sample Output 2 :
1
Explanation of Sample Input 2:
The input character is uppercase, so our answer is 1.
Sample Input 3 :
#
Sample Output 3 :
-1
Explanation of Sample Input 3:
The input character is not an alphabet, so our answer is -1.
Constraints :
The input can be any single character.
*/
#include<iostream>
using namespace std;
int main() {
// Write your code here
char x;
cin>>x;
if(char(65)<=x && x<=char(90))
{
cout<<"1"<<endl;
}
else if(char(97)<=x && x<=char(122))
{
cout<<"0"<<endl;
}
else
{
cout<<"-1"<<endl;
}
return 0;
}