Showing posts with label toupper() function. Show all posts
Showing posts with label toupper() function. Show all posts

Wednesday, May 26, 2021

, , , , , ,

toupper() function in c with exmaple program

 toupper() function in c programming is used to convert lowercase alphabets to uppercase letters.

When a programmer passed a lowercase alphabet to toupper() function then it converts it to uppercase.

Or when a uppercase alphabet is passed then function returns same value.

Syntax for toupper() function in c :-

int toupper(int ch);

Example Program for toupper() in c :- 

Let's go with an simple s example program to convert lower case alphabet to uppercase using toupper() function.


#include <ctype.h> 

int main() 
{ 
    char ch; 

    // letter to convert to uppercase
    ch = 'a'; 

    printf("%c in uppercase is represented as %c", 
        ch, toupper(ch)); 

    return 0; 
} 


Note :- Remember toupper() in c only takes one character at a time.

So if you want to convert a hole word then use while loop for it