Easy Tutorial
❮ C Function Fscanf C Exercise Example56 ❯

C Library Function - islower()

C Standard Library - <ctype.h>

Description

The C library function int islower(int c) checks whether the passed character is a lowercase letter.

Declaration

Here is the declaration for the islower() function.

int islower(int c);

Parameters

Return Value

If c is a lowercase letter, the function returns a non-zero value (true); otherwise, it returns 0 (false).

Example

The following example demonstrates the use of the islower() function.

#include <stdio.h>
#include <ctype.h>

int main()
{
   int var1 = 'Q';
   int var2 = 'q';
   int var3 = '3';

   if( islower(var1) )
   {
       printf("var1 = |%c| is a lowercase letter\n", var1 );
   }
   else
   {
      printf("var1 = |%c| is not a lowercase letter\n", var1 );
   }
   if( islower(var2) )
   {
       printf("var2 = |%c| is a lowercase letter\n", var2 );
   }
   else
   {
      printf("var2 = |%c| is not a lowercase letter\n", var2 );
   }
   if( islower(var3) )
   {
       printf("var3 = |%c| is a lowercase letter\n", var3 );
   }
   else
   {
      printf("var3 = |%c| is not a lowercase letter\n", var3 );
   }

   return(0);
}

Let's compile and run the above program, which will produce the following result:

var1 = |Q| is not a lowercase letter
var2 = |q| is a lowercase letter
var3 = |3| is not a lowercase letter

C Standard Library - <ctype.h>

❮ C Function Fscanf C Exercise Example56 ❯