C++ isupper()

isupper() Prototype

int isupper(int ch);

The isupper() function checks if ch is in uppercase as classified by the current C locale. By default, the characters from A to Z (ascii value 65 to 90) are uppercase characters.

The behaviour of isupper() is undefined if the value of ch is not representable as unsigned char or is not equal to EOF.

It is defined in <cctype> header file.

isupper() Parameters

ch: The character to check.

isupper() Return value

The isupper() function returns non zero value if ch is in uppercase, otherwise returns zero.

Example: How isupper() function works

#include <cctype>
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    char str[] = "This Program Converts ALL UPPERCASE Characters to LOWERCASE";

    for (int i=0; i<strlen(str); i++)
    {
        if (isupper(str[i]))
            /*  Converting uppercase characters to lowercase  */
            str[i] = str[i] + 32;
    }

    cout << str;
    return 0;
}

When you run the program, the output will be:

this program converts all uppercase characters to lowercase
Did you find this article helpful?