convert uppercase to lowercase in C

In this program you will learn how you can convert string from uppercase to lowercase, In C language every character represent as a integer value known as ASCII. ASCII value of small letter (a-z) are (97-122) and capital (A-Z) are (65-90)

void main()
 char str[20];
 int i;
 printf("\n enter a string:");
    //it will convert uppercase to lowercase
    if(str[i]>=65 && str[i]<=90)
 printf(" %s",str);


enter a string:WELCOME TO MY WEBSITE
welcome to my website

working of uppercase to lowercase program in C

  • input string from the user, and store it some variable let say str
  • run the loop from 0 till end of string
  • When you want to change from uppercase to lowercase, you have to add the ASCII value of uppercase letters to 32. why adding it with 32 because diffrence of a-A=32
  • For example: A+32=a i.e 65+32=97
  • 65 is ASCII value of capital A and 97 is ASCII value of small a