C++ Program to convert uppercase string to lowercase


In this program, You will learn how to convert uppercase string to lowercase in C++.


Enter a String:XIIth

Lowercase String is:xiith

Example: How to convert uppercase string to lowercase in C++.

#include<iostream>
using namespace std;

int main() {

    char str[100];
    int i = 0;

    cout << "Enter a string:";
    cin.getline(str, 100);

    while (str[i] != '\0') {
        i++;
    }

    for (int j = 0; j < i; j++) {
        if (str[j] >= 65 && str[j] <= 90) {
            str[j] = str[j] + 32;
        }
    }
    cout << "Lowercase string is:" << str;

    return 0;
}

Output:

Enter a string:WELCOME TO XIITH.COM
Lowercase string is:welcome to xiith.com