The toupper() function is used to convert lowercase alphabet to uppercase. i.e. If the character passed is a lowercase alphabet then the toupper() function converts a lowercase alphabet to an uppercase alphabet. It is defined in the ctype.h header file.
Syntax:
int toupper(int ch);
Parameter: It accepts a single parameter:
- ch: This represents the character to be converted to uppercase.
Returns: This function returns the uppercase character corresponding to the ch.
Below programs illustrate the toupper() function in C:
Example 1:-
// C program to demonstrate // example of toupper() function. #include <ctype.h> #include <stdio.h> int main() { char ch; ch = 'g'; printf("%c in uppercase is represented as %c", ch, toupper(ch)); return 0; } |
g in uppercase is represented as G
Example 2:-
// C program to demonstrate // example of toupper() function. #include <ctype.h> #include <stdio.h> int main() { int j = 0; char str[] = "geekforgeeks\n"; char ch; while (str[j]) { ch = str[j]; putchar(toupper(ch)); j++; } return 0; } |
GEEKFORGEEKS
Recommended Posts:
- arc function in C
- putwchar() function in C/C++
- vwprintf() function in C/C++
- vswscanf() Function in C/C++
- iswupper() function in C/C++
- Address of a function in C or C++
- iswlower() function in C/C++
- iswcntrl() function in C/C++
- towctrans() function in C/C++
- fegetenv() function in C/C++
- wctrans() function in C/C++
- wmemcpy() function in C/C++
- fegetexceptflag() function in C/C++
- vswprintf() function in C/C++
- wcrtomb() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



