Write a C++ program to accept a character and determine whether it’s upper case or lower case.

Q17. Write a C++ program to accept a character and determine whether it’s upper case or lower case.

Solution:

#include<iostream.h> //standard input/output header file

#include<conio.h> //for clrscr()

 

int main()

{

char a;

 

clrscr(); //for clearing the screen

 

cout<<“\n Enter any character: “;

cin>>a;

 

a>=90?cout<<“\n It is a lower case letter.” : cout<<“\n It is an upper case letter.”;

 

getch(); //holds the screen until any key is pressed

return 0; //makes main() finish

}

 

OUTPUT:

CASE 1:

Enter any character: r

 

It is a lower case letter.

 

CASE 2:

Enter any character: R

 

It is an upper case letter.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: