C islower()

The islower() function defined in the ctype.h header file. It helps to check the specified character is a lowercase alphabet (a-z) or not.


int islower( int argument ); #where argument will be a character
 

islower() Parameters:

The islower() function takes a single parameter and is in the form of an integer and the return value should be an integer. When a character is passed it is converted into the integer value corresponding to its ASCII value.

Parameter Description Required / Optional
argument  The character to be checked Required

islower() Return Value

 If the given character is a lowercase alphabet, islower() returns a non-zero integer else zero. When a lowercase alphabet character is passed we will get a different non-zero integer.

Input Return Value
Zero If the parameter isn't a lowercase alphabet
Non zero number If the parameter is a lowercase alphabet

Examples of islower()

Example 1: Working of islower() function in C


#include <stdio.h>
#include <ctype.h>
int main()
{
    char ch;

    ch='a';
    printf("If %c is passed to islower(): %d", ch, islower(ch));

    c='A';
    printf("\nIf %c is passed to islower(): %d", ch, islower(ch));

    return 0;
}

Output:


If a is passed to islower(): 2
If A is passed to is islower(): 0

Example 2: How islower() function works in C?


#include <stdio.h>
#include <ctype.h>
int main()
{
    char ch;

    printf("Please enter a character: ");
    scanf("%c", &ch);

    if (islower(ch) == 0)
         printf("The given %c is not a lowercase alphabet.", ch);
    else
         printf("The given %c is a lowercase alphabet.", ch);

    return 0;
}

Output:


Please enter a character: h
The given h is a lowercase alphabet.