tolower() function in C

The tolower() function is defined in the ctype.h header file. If the character passed is a uppercase alphabet then the tolower() function converts a uppercase alphabet to an 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:-

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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;
}

chevron_right


Output:

G in lowercase is represented as = g

Example 2:-

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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;
}

chevron_right


Output:

geeksforgeeks


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.