Wednesday 9 March 2016

CHARACTER – UPPER OR LOWER


Write a program that accepts a character as input and checks whether it is an uppercase letter or lowercase letter or neither.

Input Format: 
Input consists of a single character.

Output Format: 
Output consists of a single line. Refer sample output for the format.

Sample Input 1 : 
c

Sample Output 1 : 
c is lowercase letter

Sample Input 2: 
A

Sample Output 2: 
A is uppercase letter

Sample Input 3: 
5

Sample Output 2: 
5 is neither an uppercase or lowercase letter

Code:
  #include<stdio.h>
int main()
{
  char a;
  scanf("%c",&a);
  if(a>='A' && a<='Z')
  printf("%c is uppercase letter",a);
  else if(a>='a' && a<='z')
  printf("%c is lowercase letter",a);
    else
  printf("%c is neither an uppercase or lowercase letter",a);
  return 0;
}
  

No comments:

Post a Comment