C Programming Code Examples C > Strings Code Examples C program to convert string to lowercase C program to convert string to lowercase Write a C program to convert uppercase string to lowercase using for loop. How to convert uppercase string to lowercase without using inbuilt library function strlwr(). How to convert string to lowercase using strlwr() string function. Logic to convert uppercase string to lowercase 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). Algorithm to convert uppercase to lowercase %%Input : text {Array of characters / String} N {Size of the String} Begin: For j = 0 to N do If (text[j] >= 'A' and text[j] <= 'Z') then text[j] = text[j] + 32; End if End for End /** C program to convert string to lowercase */ #include <stdio.h> #define maxsize 100 // Maximum string size int main() { char str[maxsize]; int j; /* Input string from user */ printf("Enter any string: "); gets(str); // Iterate loop till last character of string for(j=0; str[j]!='\0'; j++) { if(str[j]>='A' && str[j]<='Z') { str[j] = str[j] + 32; } } printf("Lower case string: %s", str); return 0; }