Problem Description
Write a C program to convert uppercase string to lowercase using inbuilt string library function strlwr(). How to use strlwr library function in C programming. Internally characters in C are represented as an integer value known as ASCII value. Which means if we write a or any other character it is translated into a numeric value in our case it is 97 as ASCII value of a = 97.
Here what we need to do is first we need to check whether the given character is upper case alphabet or not. If it is uppercase alphabet just add 32 to it which will result in lowercase alphabet (Since ASCII value of A=65, a=97 their difference is 97-65 = 32).CODING ARENA
#include <stdio.h>
#include<string.h>
int main()
{
char str[100];
int i;
scanf("%s",str);
for(i=0;i<=strlen(str);i++)
{
if(str[i]>=65&&str[i]<=90)
str[i]=str[i]+32;
}
printf("%s",str);
return 0;
}
Test Case 1
Input (stdin)SRMUNIVERSITYLEARNINGCENTRE
Expected Outputsrmuniversitylearningcentre
Test Case 2
Input (stdin)SRMAPPLELAB
Expected Outputsrmapplelab
No comments:
Post a Comment