Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

tolower() function in C

  • Difficulty Level : Easy
  • Last Updated : 17 Dec, 2021

The tolower() function is defined in the ctype.h header file. If the character passed is an uppercase alphabet then the tolower() function converts an uppercase alphabet to a lowercase alphabet.
Syntax: 
 

int tolower(int ch);

Parameter: This method takes a mandatory parameter ch which is the character to be converted to lowercase.
Return Value: This function returns the lowercase character corresponding to the ch.
Below programs illustrate the tolower() function in C:
Example 1:-
 

c




// C program to demonstrate
// example of tolower() function.
 
#include <ctype.h>
#include <stdio.h>
 
int main()
{
 
    // Character to be converted to lowercase
    char ch = 'G';
 
    // convert ch to lowercase using toLower()
    printf("%c in lowercase is represented as = %c", ch, tolower(ch));
 
    return 0;
}


Output: 

G in lowercase is represented as = g

 

Example 2:-
 

c




// C program to demonstrate
// example of tolower() function.
 
#include <ctype.h>
#include <stdio.h>
 
int main()
{
    int j = 0;
    char str[] = "GEEKSFORGEEKS\n";
 
    // Character to be converted to lowercase
    char ch = 'G';
 
    // convert ch to lowercase using toLower()
    char ch;
 
    while (str[j]) {
        ch = str[j];
 
        // convert ch to lowercase using toLower()
        putchar(tolower(ch));
 
        j++;
    }
 
    return 0;
}


Output: 



geeksforgeeks

 

Note:  

If the character passed in the tolower() is any of these three

1. lowercase character

2. special symbol

3. digit

tolower() will return the character as it is.

Example :

C




// C program to demonstrate
// example of tolower() function.
#include <ctype.h>
#include <stdio.h>
 
int main()
{
    int j = 0;
    char str[] = "GeEks@123\n";
    char ch;
 
    while (str[j]) {
        ch = str[j];
        putchar(tolower(ch));
        j++;
    }
 
    return 0;
}
// code is contributed by codersaty


Output

geeks@123




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!