5. Program that allows the user to enter a letter, and then displays either zero or nonzero, depending on whether a lowercase or uppercase letter was entered.

Chapter 2: 

C++ Programming Basics 

Programming Exercise

Problem # 5:

A library function, islower(), takes a single character (a letter) as an argument and returns a nonzero integer if the letter is lowercase, or zero if it is uppercase. This function requires the header file CTYPE.H, Write a program that allows the user to enter a letter, and then displays either zero or nonzero, depending on whether a lowercase or uppercase letter was entered.

Solution:

#include<iostream>
#include<conio.h>
#include<CTYPE.H>
using namespace std;
int main()
{
    char ch;
    int result;
    cout<<"Enter a character:";
    cin>>ch;
    result=islower(ch);
    if(result!=0)
        cout<<"Entered character is a Lowercase!"<<endl;
    else
        cout<<"Entered character is an Uppercase!"<<endl;
  
    return 0;
}

Let me know in the comment section if you have any question.

Previous Post:
4. Program that displays your favorite poem. Use an appropriate escape sequence for the line breaks.

Comments