Program to convert string to lowercase c++

Write a Program to convert string to lowercase C++ without using library function tolower( ).

PROGRAM:

#include<iostream>
using namespace std;

int main( )
{

    char str[80];
    cout<<"Enter a string:";
    gets(str);

    for(int i=0;str[i]!='';i++)
        str[i] = (str[i]>='A' && str[i]<='Z')?(str[i]+32):str[i];

    cout<<str;


    return 0;
}

 

OUTPUT:

convert string to lowercase c++

Leave a Reply