Convert a character from uppercase to lowercase

Q. Write a C++ program to convert a character from uppercase to lowercase.

Answer:

Following program is converting a character a from uppercase to lowercase.

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
        char str[20];
        int i;
        cout<<"\n Enter String in Uppercase : ";
        cin>>str;
        for(i=0; i<=strlen(str); i++)
        {
                if(str[i]>=65 && str[i]<=90)  //65 to 90 is an ASCII values of 'A' to 'Z'
                {
                        str[i]=str[i]+32;
                }
        }
        cout<<"\n Conversion of above String into Lowercase : "<<str;
        return 0;
}


Output:

convert upper to lower