Covert a character from lowercase to uppercase

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

Answer:

Following program is converting a character from lowercase to uppercase.

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


Output:

convert lower to upper