The C islower(), isupper(), tolower(), toupper() functions usage

 

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows 2003 Server Standard Edition

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)

Other info:

To do: Testing characters using islower(), isupper(), tolower(), toupper() C functions

To show: The islower(), isupper(), tolower(), toupper() C functions usage

 

 

// Using functions islower(), isupper(), tolower(), toupper()

#include <stdio.h>

#include <string.h>

 

int main(void)

{

printf("Using functions islower(), isupper(),\n");

printf("tolower(), toupper()\n");

printf("-------------------------------------");

 

printf("\nAccording to islower()\n");

islower('p') ? printf("p is a lowercase letter\n") : printf("p is not a lowercase letter\n");

islower('P') ? printf("P is a lowercase letter\n") : printf("P is not a lowercase letter\n");

islower('5') ? printf("5 is a lowercase letter\n") : printf("5 is not a lowercase letter\n");

islower('!') ? printf("! is a lowercase letter\n") : printf("! is not a lowercase letter\n");

 

printf("\nAccording to isupper()\n");

isupper('D') ? printf("D is a uppercase letter\n") : printf("D is not a uppercase letter\n");

isupper('d') ? printf("d is a uppercase letter\n") : printf("d is not a uppercase letter\n");

isupper('8') ? printf("8 is a uppercase letter\n") : printf("8 is not a uppercase letter\n");

isupper('$') ? printf("$ is a uppercase letter\n") : printf("$ is not a uppercase letter\n");

 

printf("\nConversion....\n");

printf("u converted to uppercase is %c\n",(char)toupper('u'));

printf("7 converted to uppercase is %c\n",(char)toupper('7'));

printf("$ converted to uppercase is %c\n",(char)toupper('$'));

printf("L converted to lowercase is %c\n",(char)tolower('L'));

 

return 0;

}

 

Output example:

 

Using functions islower(), isupper(),

tolower(), toupper()

-------------------------------------

According to islower()

p is a lowercase letter

P is not a lowercase letter

5 is not a lowercase letter

! is not a lowercase letter

According to isupper()

D is a uppercase letter

d is not a uppercase letter

8 is not a uppercase letter

$ is not a uppercase letter

Conversion....

u converted to uppercase is U

7 converted to uppercase is 7

$ converted to uppercase is $

L converted to lowercase is l

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index