C Toupper - C Standard Library

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Firefox https://www.programiz.com/c-programming/library-function/ctype.h/to...

C toupper()
The toupper() function converts a lowercase alphabet to
an uppercase alphabet.

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> (/c-


programming/library-function/ctype.h) header file.

1 of 2 9/9/2022, 10:18 PM
Firefox https://www.programiz.com/c-programming/library-function/ctype.h/to...

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

2 of 2 9/9/2022, 10:18 PM

You might also like