C Program to convert uppercase string to lowercase


In this program, You will learn how to convert uppercase string to lowercase in c.


Hello Abc => hello abc

Welcome to Xiith => welcome to xiith

Example: How to convert uppercase string to lowercase in c.

#include<stdio.h>

int main() {

   char str[100];
   int i = 0;

   printf("Enter a string:");
   scanf("%[^\n]%*c", str); 

   while (str[i] != '\0') {
       i++;
   }

   for (int j = 0; j < i; j++) {
       if (str[j] >= 65 && str[j] <= 90)
           str[j] = str[j] + 32;
   }
   printf("Lowercase string:%s", str);

   return 0;
}

Output:

Enter a string:Xiith
Lowercase string:xiith