Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Arrays and Strings
  5. Strings
  6. String Lower

String Lower

strlwr()

Converts upper case string to lowercase

strlwr(string_name);

Program: Convert string to lowercase using library function

#include<stdio.h>
#include<string.h>
int main() 
{
    char s[100];
    puts("Ener string in uppercase");
    gets(s);
    strlwr(s);
    puts("After converting to lowercase,");
    puts(s);
    return 0;
}

Output

Ener string in uppercase
ITECHBITZ
After converting to lowercase,
itechbitz

Program: Convert string to lowercase without using library function

#include<stdio.h>
#include<string.h>
int main()
{
    char s[100];
    int i=0;
    puts("Enter string in uppercase");
    gets(s);
    while(s[i] != '\0')
    {
        if(s[i] >=65 && s[i]<=90)
        {
            s[i] = s[i] +32;
            i++;
        }
    }
    puts("After converting to lowercase");
    puts(s);
    return 0;
}

Output

Enter string in uppercase
ITECHBITZ
After converting to lowercase
itechbitz

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments