×

tolower() Function in C

The tolower() capability is characterized in the ctype.h header document. In the event that the person passed is a capitalized letter set, the tolower() capability switches capitalized letters in order over completely to lowercase letters in order.

Syntax:

int tolower(int ch);

Essentially tolower() returns an int esteem, and in C language, we can client %c to switch that int esteem over completely to roast worth. However, in c++, pigeonholing is required this way:

char c = (char) tolower(‘A’);

Parameters: This strategy takes a compulsory boundary ch which is the person to be switched over entirely to lowercase.

Return Value: This capability returns the lowercase person compared to the ch.

Example:

// Simple C program to demonstrate the tolower() function 
// example of tolower() function in C.
#include <ctype.h>   //here, we are including the ctype.h module into our program
#include <stdio.h>    //here, we are including the stdio.h module into our program
#include <conio.h>   //here, we are including the conio.h module into our program
int main()
{
    // here, we are giving the input as Characters that are to be converted to the //Lowercase Characters
    char ch = “Vijay”;
    clrscr();   //this function is used to clear the screen before printing the characters
    // here, we are converting the ch data to the lowercase character using toLower() //function
    printf(“Hello World, Welcome to the program”);   //here, we are printing the //simple output statement 
    printf("The given %c in lowercase is represented as = %c", ch, tolower(ch));
    return 0;
}

Output:

Hello world, Welcome to the program.
The given Vijay in lowercase is represented as = vijay

Example 1:

// Simple C program to demonstrate the tolower() function for more than 2 //characters
// Example of tolower() function in C.
#include <ctype.h>   //here, we are including the ctype.h module into our program
#include <stdio.h>    //here, we are including the stdio.h module into our program
#include <conio.h>   //here, we are including the conio.h module into our program
int main()
{
    int j = 0;    //here, we are initializing a integer j assigned to 0
    char st[] = "VIJAY kUMAR\n";
    // the above is the given Character that is to be converted to lowercase
    char ch = 'V';
    clrscr();   //this function is used to clear the screen before printing the characters
    // here, we are converting every character to lowercase
      printf(“Hello World, Welcome to the program”);      //here, we are printing the //simple output statement 
       while (st[j]) {     //here, we are declaring a while loop to convert every single 
// character to the lowercase
        str[j] = tolower(str[j]);
        j++;     //here, we are reading every single character of the word
    }
    // here, we are printing the string that is converted into lowercase
    for (int i = 0; i < j; i++)   //here, we are using the for loop to print every character 
    printf(“Printing the characters in lower case:”);    
    printf("%c", str[i]);     //here, we are printing the characters
    return 0;
}

Output:

Hello World, Welcome to the program
Printing the characters in lowercase: vijay kumar

Note:

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

1. lowercase person

2. unique image

3. digit

tolower() will return the character for what it's worth.

Example 2:

// Simple C program to demonstrate the tolower() function for more than 2 //characters and special characters
// Example of tolower() function in C.
#include <ctype.h>   //here, we are including the ctype.h module into our program
#include <stdio.h>    //here, we are including the stdio.h module into our program
#include <conio.h>   //here, we are including the conio.h module into our program
int main()
{
         int j = 0;     //here, we are initializing a integer j assigned to 0
    char st[] = "ViJay@123\n";     //here, we are initializing the Character st with some //uppercase, lowercase and special characters
    char ch;     //here, we are declaring the character variable ch
    printf(“Hello World, Welcome to the program”);        //here, we are printing the //simple output statement 
    printf(“Printing the characters in lowercase”);
     while (str[j]) {        //here, we are declaring a while loop to convert every single 
// character to the lowercase
        ch = str[j];
        putchar(tolower(ch));      //here, we are converting the uppercase characters to //the lowercase characters
        j++;
    }
    return 0;
}

Output:

Hello World, Welcome to the program.
Printing the characters in lowercase:
vijay@123

Related Topics

Bubble sort in C

Bubble sort in C Bubble sort is defined as the algorithm that is used for the sorting mechanism. It follows the technique of replacing the first index with the more minor...

4 minutes read.

How to create a node in C?

A node is a small concept taken from the graph theory, or a node is a fundamental unit of a data structure, like a tree data structure. Every graph contains...

3 minutes read.

Memory layout in C

Memory layout in C The C language is designed so that it becomes easier for a programmer to decide the amount of memory they want to use in a program. C program...

4 minutes read.

Booleans in C

Introduction to Boolean With all the complexities of programming, it can take time to understand the basics. One concept, in particular, that confuses many beginners is the use of Booleans in...

6 minutes read.

C Program Swap Numbers in cyclic order Using Call by Reference

The three integers that the user entered in cyclical sequence are swapped in this tutorial using call by reference. C Program: #include <stdio.h> void cyclic_Swap ( int *X, int *Y, int *Z ); int...

2 minutes read.

Branching Statements in C

What is branching in c? Branching gets its name from the fact that the computer can select which branch to follow.Programs written in the C language execute statements one after the...

6 minutes read.

Fibonacci series in C

We have learned about the Fibonacci series in mathematics. For a quick recap, A Fibonacci series is the sequence of numbers following a certain pattern i.e., the next number should...

3 minutes read.

Use of fflush(stdin) in C

Use of fflush(stdin) in C Usually, fflush() is only used for the output stream. The purpose is to clean (or flush) the output buffer and transfer the buffered data into...

2 minutes read.

LCM of two numbers in C

LCM is a mathematical term which stands for Least Common Multiple. LCM of any two numbers is the smallest positive value(number) which is evenly divisible by the two given numbers. Consider...

4 minutes read.

Escape Sequence in C

An escape sequence is a sequence of character that used inside the string literal or character.  All the escape sequence is used with the backslash (\) symbol. The list of an...

1 minute read.

Fibonacci Series in C Using For Loop

In this C article, we will let you know about the procedure of displaying the Fibonacci series of the first “n” positive integers. The syntax of for loop used in the...

4 minutes read.

Float in islower() in C

Introduction: This article briefly discusses the float in islower() in C. The islower() function checks if the input character passed inside the function is lowercase. Lowercase letters include (a-z). The islower()...

4 minutes read.

How to use sine() function in C

What is Function? The function is a set of statements. It takes input and performs some computation to produce output. The process is a set of codes only achieved when it is...

3 minutes read.

C Programming Tutorial

What is C Programming C is most popular and widely used computer programming language. It was developed by Dennis Ritchie in 1972 at the Bell Lab. It is used to develop system application software. There...

8 minutes read.

Dynamic memory allocation

Dynamic memory allocation is used to allocate the memory at runtime. It has following function within <stdlib.h> header file. Function Syntax malloc() malloc (number *sizeof(int)); calloc() calloc (number, sizeof(int)); realloc() realloc (pointer_name, number * sizeof(int)); free() free (pointer_name); malloc() function The process...

2 minutes read.

GCD of Two Numbers in C

The GCD means the greatest common divisor of two or more integers, it is also called as hcf. The gcd returns the greatest integer of the given two integers that...

3 minutes read.

Git Hooks

Git Hooks Overview Just like other version control systems, Git has its way to deliver customized scripts whenever some important activity occurs. The hooks act just like the triggers or catalysts...

4 minutes read.

memcmp() in C

Introduction: In this article we are discuss about memcmp() function in C. This function permits the person to evaluate the bytes of the two characters, as mentioned above. Depending on...

4 minutes read.

C Pointers

Pointers in C A pointer is a variable, which contains the address of another variable, i.e., it’s a variable which has the address of another variable as its value. The utilization...

4 minutes read.

Hexadecimal to Binary in C

What is hexadecimal? Hexadecimal defines a sequence of numbers centered on-16, i.e., before assigning the next number to a new location, it describes a numbering scheme that includes 16 sequential numbers as basic...

2 minutes read.