59.5k views
1 vote
Write an application named EnterUppercaseLetters that asks the user to type an uppercase letter from the keyboard. If the character entered is an uppercase letter, display OK; if it is not an uppercase letter, display an error message. The program continues until the user types an exclamation point. Grading When you have completed your program, click the Submit button to record your score.

User Abhinaya
by
4.2k points

1 Answer

5 votes

Answer:

Program is in C++

Step-by-step explanation:

C++ Code:

#include <iostream>

#include <cctype>

using namespace std;

int main(){

char ch;

do{

cout<<"Enter Character: ";

cin>>ch;

if (isupper(ch)){

cout<<"OK"<<"\\";

}

}

while(ch!='!');

return 0;

}

_______________________________________

Code Explanation

First execute a do while loop as we want user to enter at least first character to check whether its upper case or not. If user enters exclamation character then this loop will terminate along with the program.

To check whether the entered character is upper case or not we will be using isupper(ch) method defined in cctype library.

If the character is upper case then if condition will show Ok by printing it using cout and this program will show nothing if the character is not upper case.

Sample Output

Enter Character: A

OK

Enter Character: b

Enter Character: c

Enter Character: d

Enter Character: E

OK

Enter Character: G

OK

Enter Character: F

OK

Enter Character: !

User Rhys
by
5.0k points