C Program to convert uppercase string to lowercase

Category: C Program

C Program to convert uppercase characters in a string to lowercase characters using loop or strlwr string function. How to convert uppercase characters in a string to lowercase characters using loop or strlwr string function. Logic to convert uppercase characters in a string to lowercase characters in C language.

C Program to convert lowercase string to uppercase using loop

#include <stdio.h>

void main()
{
  char str[50];
  int i=0;

  printf("Enter uppercase string: ");
  gets(str);

  for (i = 0; str[i] != '\0'; i++)
  {
    if(str[i]>='a' && str[i]<='z')
    {
      str[i] = str[i] + 32;
    }
  }

  printf("Lowercase string: %s", str);
}

C Program to convert lowercase string to uppercase using strlwr() function

#include <stdio.h>
#include <string.h>

void main()
{
  char str[50];

  printf("Enter uppercase string: ");
  gets(str);

  strlwr(str);

  printf("Lowercase string: %s", str);
}

Output

Enter uppercase string: PROCODING
Lowercase string: procoding

Recommended Posts