C++ Program to convert lowercase string to uppercase


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


Enter a String: hello

Uppercase String is: HELLO


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

Run it Now
#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] >= 97 && str[j] <= 122)
            str[j] = str[j] - 32;
    }
    cout << "\nUpperCase String is :" << str;

    return 0;
}

Output:

Enter a String :level
UpperCase String is :LEVEL