toupper() and tolower() Functions in C Language (C Language में toupper() और tolower() Functions)
1. toupper() Function
The toupper() function is used to convert a lowercase alphabet into an uppercase alphabet. It is declared in the <ctype.h> header file.
toupper() फंक्शन का उपयोग छोटे अक्षर (Lowercase) को बड़े अक्षर (Uppercase) में बदलने के लिए किया जाता है। यह <ctype.h> Header File में Defined है।
Syntax:
toupper(character);Example:
char ch = 'a';printf("%c", toupper(ch));
Output:
AC Program Using toupper()
#include <stdio.h>#include <ctype.h>int main(){char ch;printf("Enter a character: ");scanf("%c", &ch);printf("Uppercase character: %c", toupper((unsigned char)ch));return 0;}
Output:
Enter a character: aUppercase character: A
2. tolower() Function
The tolower() function is used to convert an uppercase alphabet into a lowercase alphabet. It is also declared in the <ctype.h> header file.
tolower() फंक्शन का उपयोग बड़े अक्षर (Uppercase) को छोटे अक्षर (Lowercase) में बदलने के लिए किया जाता है। यह भी <ctype.h> Header File में Defined है।
Syntax:
tolower(character);Example:
char ch = 'A';printf("%c", tolower(ch));
Output:
aC Program Using tolower()
#include <stdio.h>#include <ctype.h>int main(){char ch;printf("Enter a character: ");scanf("%c", &ch);printf("Lowercase character: %c", tolower((unsigned char)ch));return 0;}
Output:
Enter a character: ALowercase character: a
Important Points
Both functions are defined in
<ctype.h>.toupper()converts lowercase letters into uppercase.tolower()converts uppercase letters into lowercase.Both functions return the converted character as an integer value.
If the character has no corresponding uppercase or lowercase form, it remains unchanged.
These functions work on one character at a time.
महत्वपूर्ण बिंदु:
दोनों Functions
<ctype.h>Header File में Defined हैं।toupper()छोटे अक्षर को बड़े अक्षर में बदलता है।tolower()बड़े अक्षर को छोटे अक्षर में बदलता है।दोनों Functions Converted Character को Integer Value के रूप में Return करते हैं।
यदि Character का Uppercase या Lowercase रूप उपलब्ध नहीं है, तो वह अपरिवर्तित रहता है।
ये Functions एक समय में एक Character पर कार्य करते हैं।
Note: To convert an entire string, use a loop with toupper() or tolower() on each character. Always pass either EOF or a value representable as unsigned char to these functions.
Comments
Post a Comment