islower() in C
The islower() function is used to check whether the entered character passed inside the function is a lowercase character. The lowercase character includes (a-z).
Syntax of islower() In C Programming
int islower( int arg);
Parameters Passed in islower() Function
c: It requires only one parameter. The c represents a character that is required to be checked.
Two possible values can be returned after using the islower() function. They can be
Non-zero value: It returns a non-zero value when the character passed to the islower() function is a lowercase character.
0: The function returns a zero (0) if the character is not lowercase.
Implementation of islower() function in C Programming
The islower() function in C Program checks that a character is typed in lowercase and not uppercase. It only returns a number other than zero if the character is one of them: a b c d e f g h i j k l m n o p q r s t u v w x y z.
The islower() function is declared in the ctype.h header file. It is necessary to include this header file to use this function as the function definition is in this file.
For any character the islower() function returns a non-zero value. The functions such as iscntrl, isdigit, ispunct and isspace will return zero for the same character.
Input value: z
Output: Non-zero value
Input value: U
Input value: $
Input value: c
Output: Non-zero value
Implement a C Program to Check Whether a Character is a lowercase character or not
The user can input any valid character from the keyboard. The program will pass that character into the islower() function, determining whether the character is in lowercase.
Using the islower() Function to write more complex programs
There are multiple applications of the islower() function. Some of these applications are implemented below:
Count the lowercase characters in a given string
To find out the number of lowercase characters in the string, we are required to follow these steps:
Print the Characters of the String Until you have encountered a Lowercase Character in the string
This is also a popular coding question. The aim is to print a string till you encounter the first lowercase character in the string. It is easy to code this problem by simply using the islower() function in the C Programming language.
Let us code the actual program using the above algorithm.
Print the First Lowercase Character in the given string
Another application of the islower() function in C Programming is that we can easily determine the first lowercase character present in the string. Let us discuss two different approaches to solving this problem. One method to solve this is by performing iterations. The other method is by solving the problem using recursion in your code.
It is quite simple and straightforward. We will perform a linear search on the string. The difference is that here we will use the searching algorithm with the islower() function to find the very first lowercase character in the string.
Next Topicmemcpy() in C