islower() in C
0 222
The "islower()" function in C is a part of the standard C library
It checks whether a given character is a lowercase alphabetic letter.
Syntax of islower():
#include<ctype.h>int islower(int c);
Parameters:
c: It's an integer representing the character to be checked.
Return Value:
The function returns a value greater than zero if the character is a lowercase letter.
Returns 0 otherwise.
Algorithm:
The function takes an integer representing a character as input.
It checks if the character is within the range of lowercase alphabetic characters(ASCII values 97 to 122).
If the character is a lowercase letter, the function returns a value that is not zero.
Example:
Using islower() to Check Lowercase Character:
// program for Using islower() to check lowercase character #include<stdio.h>#include<ctype.h> int main() { char ch = 'a'; if (islower(ch)) { printf("%c is a lowercase character.\n", ch); } else { printf("%c is not a lowercase character.\n", ch); } return 0; }
Output:
a is a lowercase character.
Counting Lowercase Characters in a String:
// program for counting lowercase characters in a string #include<stdio.h>#include<ctype.h> int main() { char str[] = "Hello World"; int count = 0; for (int i = 0; str[i] != '\0'; i++) { if (islower(str[i])) { count++; } } printf("Number of lowercase characters in the string: %d\n", count); return 0; }
Output:
Number of lowercase characters in the string: 8
Share:
Comments
Waiting for your comments