C toupper()

The function prototype of the toupper() function is:

int toupper(int ch);

toupper() Parameters

The function takes a single argument.

  • ch - a character

Return value from toupper()

If an argument passed to toupper() is

  • a lowercase character, the function returns its corresponding uppercase character
  • an uppercase character or a non-alphabetic character, the function the character itself

The toupper() function is defined in the <ctype.h> header file.


Example: C toupper() function

#include <stdio.h>
#include <ctype.h>
int main() {
    char c;

    c = 'm';
    printf("%c -> %c", c, toupper(c));

    c = 'D';
    printf("\n%c -> %c", c, toupper(c));

    c = '9';
    printf("\n%c -> %c", c, toupper(c));
    return 0;
}

Output

m -> M
D -> D
9 -> 9
Did you find this article helpful?

Your builder path starts here. Builders don't just know how to code, they create solutions that matter.

Escape tutorial hell and ship real projects.

Try Programiz PRO
  • Real-World Projects
  • On-Demand Learning
  • AI Mentor
  • Builder Community