C Program to Convert String into Uppercase and Lowercase Using strupr() and strlwr() (strupr() और strlwr() Functions in C Language)

1. strupr() Function

The strupr() function is used to convert all lowercase letters of a string into uppercase letters.

strupr() फंक्शन का उपयोग String के सभी छोटे अक्षरों (Lowercase) को बड़े अक्षरों (Uppercase) में बदलने के लिए किया जाता है।

Syntax:

strupr(string);

Example:

char str[] = "computer";
strupr(str);
printf("%s", str);

Output:

COMPUTER

C Program Using strupr()

#include <stdio.h>
#include <string.h>
int main()
{
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
str[strcspn(str, "\n")] = '\0';
strupr(str);
printf("Uppercase String: %s", str);
return 0;
}

Output:

Enter a string: computer science
Uppercase String: COMPUTER SCIENCE

2. strlwr() Function

The strlwr() function is used to convert all uppercase letters of a string into lowercase letters.

strlwr() फंक्शन का उपयोग String के सभी बड़े अक्षरों (Uppercase) को छोटे अक्षरों (Lowercase) में बदलने के लिए किया जाता है।

Syntax:

strlwr(string);

Example:

char str[] = "COMPUTER";
strlwr(str);
printf("%s", str);

Output:

computer

C Program Using strlwr()

#include <stdio.h>
#include <string.h>
int main()
{
char str[100];
printf("Enter a string: ");
fgets(str, sizeof(str), stdin);
str[strcspn(str, "\n")] = '\0';
strlwr(str);
printf("Lowercase String: %s", str);
return 0;
}

Output:

Enter a string: COMPUTER SCIENCE
Lowercase String: computer science

Important Points

  • strupr() converts lowercase letters into uppercase.

  • strlwr() converts uppercase letters into lowercase.

  • Both functions modify the original string.

  • Both functions are non-standard C functions and are not available in all modern compilers.

महत्वपूर्ण बिंदु:

  • strupr() छोटे अक्षरों को बड़े अक्षरों में बदलता है।

  • strlwr() बड़े अक्षरों को छोटे अक्षरों में बदलता है।

  • दोनों Functions Original String में बदलाव करते हैं।

  • ये दोनों Standard C Functions नहीं हैं और सभी आधुनिक Compilers में उपलब्ध नहीं होते हैं।

Note: For portable C programs, use the standard toupper() and tolower() functions from <ctype.h> to convert individual characters.

नोट: Portable C Programs के लिए <ctype.h> Header File के toupper() और tolower() Functions का उपयोग करके प्रत्येक Character को Convert किया जा सकता है।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025