ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Home » C programs » ctype.h header file functions

tolower() function of ctype.h in C

In this article, we are going to learn about the tolower() function of ctype.h header file in C programming language and use it to convert the uppercase variables in lowercase.
Submitted by Abhishek Sharma, on April 11, 2018

This function is used to make an upper-case character into the lower-case character. This function takes a character in the form of a parameter as a character and returns a character. The Character which will return will be in lower-case.

This is rather useful function and makes coding simple. This can be used in different scenario, like printing the output in the particular format irrespective of the user’s input.

Anyway you can implement your own function if you don’t want to include a whole library in your program. Just check for the ascii value and modify them.

Example:

    Input character is: 'A'
    Function will return 'a'


    Input character is: 'a'
    Function will return 'a'
ADVERTISEMENT

ctype.h - tolower() function Example in C



#include <stdio.h>
#include <ctype.h>

int main()
{
	// defining the type of variable
	char a,b,c,d,e,f,g,h,i,j;

	// assigning the value of variables
	a = 'A';
	b = 'B';
	c = 'C';
	d = 'D';
	e = 'E';

	// getting the lower case values of 
	// the above assigned variables
	f = tolower(a);
	g = tolower(b);
	h = tolower(c);
	i = tolower(d);
	j = tolower(e);


	// printing the upper case and their lower case values

	printf("Lowercase '%c' is '%c'\n", a, f);

	printf("Lowercase '%c' is '%c'\n", b, g);

	printf("Lowercase '%c' is '%c'\n", c, h);

	printf("Lowercase '%c' is '%c'\n", d, i);

	printf("Lowercase '%c' is '%c'\n", e, j);

	return 0;
}

Output

ctype.h - tolower()  in c language

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.