×

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

Array to function in C

Array to function in C We can create functions that receive an array as an argument. To pass an array into a function, we need to write the name of the...

4 minutes read.

Data Structures And Algorithms in C

C language is one of the most flexible and simple languages. So, it is always better to learn any concept in C language compared to other languages. Let us look...

13 minutes read.

Pointer in C

Pointer is a variable that is used to contain the address of another variable. We can easily create a pointer in C language. Example: int *ptr Symbol Description & (ampersand sign) Address of an operator...

1 minute read.

Range of int in C

In this session we know about the rage of the int in C language with the suitable examples and the programs. Firstly, we can learn the range of int: The int is...

3 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.

Union Program in C

 How should a union be defined?  In C programming, a Union is a method used to organize different data types into groups in the same way that Structures are used. We...

4 minutes read.

Pointer arithmetic in C

In the C programming language, a pointer is an address which stores a numeric value. Hence, a developer can perform several arithmetic operations on the same just as one does...

4 minutes read.

getch() function in C

getch() is a pre-define or built-in function present in the conio.h library. It returns the given character immediately without waiting for the enter key to be entered. By using getch()...

3 minutes read.

Round Robin Scheduling in C

Round Robin Scheduling in C Round robin is a CPU (Central Processing Unit) scheduling algorithm designed to share the time systems. It is one of the simplest and easiest scheduling algorithms...

4 minutes read.

Multithreading in C interview questions

Q1. What exactly is a thread? Ans: A thread is a brief sequence of instructions intended to be planned and carried out by the CPU apart from the parent process. Q2. Can...

4 minutes read.

Do WHILE LOOP in C Programming Examples

Before understanding the programming examples of the Do-While loop, we have to know what is Do-While loop in C. So, let's start with the definition of the Do-While loop. What is...

5 minutes read.

Pyramid Pattern in C

Pyramid Pattern in C A pyramid is a polyhedron created by connecting a base that will be a polygon, and all the lateral faces are triangles. All the bases are connected...

5 minutes read.

Enumeration (Enum) in C

Enumeration (Enum) in C: In the C programming language, the enum is referred to as an enumerated type. Enum is a user defined data type consisting of integer values and...

3 minutes read.

Difference between Array and List in C

C# Array vs List is where the abstraction and implementation of human computing meet.  Arrays are incredibly related to the hardware concept of contiguous and contiguous memory, where each part is...

3 minutes read.

Flow Chart of For loop in C

This is a flowchart that represents the process of executing the for loop in the C programming language. Generally, as we know there are three main components of for loop:1. The...

3 minutes read.

Bank Account System in C using File Handling

This tells about the creation of bank account system using the C language and handling of files in C. Approach Let us see the approaches and the functions how they are covering...

5 minutes read.

Types of Pointers in C

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

4 minutes read.

Variable Declaration in C

What is a Variable? A Variable is nothing more than a name for a memory place where data/information can be stored. Any alphabet (from a to z or A to Z), the...

4 minutes read.

Pointer to pointer in C

A pointer to another pointer is another type of multiple indirections and a chain of many pointers. Generally, a pointer consists of the address of the variable. Once a pointer to...

4 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.