Convert characters of String into Lowercase


This operation is used to convert all the characters of a given string into Lowercase from Uppercase. If any character in the string is already in Lowercase then it remains as it is.
In order to convert characters of given string in to Lowercase, we have to start converting from the first character in the string which is at index 0 in the array. The process of converting characters is repeated until NULL character is encountered in the string, because NULL character indicates end of the string.

Algorithm to Convert string into Lowercase


Step 1: Length = 0
Step 2: Repeat up to step 4 while S1 [Length] ≠ NULL
Step 3: If S1 [Length] >=’A’ and S1 [Length] <=’Z’ then
S2 [Length] = S1 [Length] + 32
Else
S2 [Length] = S1 [Length]
Step 4: Length = Length + 1
Step 5: S2[Length]= NULL
     

Program to Convert string into Lowercase


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char *s1,*s2;
void lower(char *s1,char *s2);
clrscr();
puts("Enter string in Uppercase:");
gets(s1);
lower(s1,s2);
puts("String Converted in Lowercase is:");
puts(s2);
getch();
}
void lower(char *s1,char *s2)
{
int length=0;
while(s1[length]!='\0')
{
if(s1[length]>='A' && s1[length]<='Z')
{
s2[length]=s1[length]+32;
}
else
{
s2[length]=s1[length];
}
length=length+1;
}
s2[length]='\0';
}

Download Projects


Download Programs