Write a program to find if a character entered by user is upper case or lower case.

 // program to find if a character entered by user is upper case or lower case.


#include<Stdio.h>

int main()

{

char ch;

printf("enter character\n");

scanf("%c", &ch);

if(ch >= 'A' && ch <= 'Z'){ 

// In, ASCII value every character have its integer value

// ASCII value of A = 65 and Z = 90

printf("upper case");

    }

    

    else if(ch >= 'a' && ch <= 'z')

    {

    printf("lower case");

}

else{

printf("invalid character");

    }

return 0;

}

Output :

enter character

G

upper case

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

Process exited after 7.554 seconds with return value 0

Press any key to continue . .


enter character

g

lower case

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

Process exited after 7.554 seconds with return value 0

Press any key to continue . .


enter character

#

invalid character

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

Process exited after 7.554 seconds with return value 0

Press any key to continue . .



Comments

Popular posts from this blog

program to (keep taking number as input from user until user enters a number which is multiple of 5.)

write a program to print the numbers from 0 to n, if n is given by user.

Write a program to print the average of 3 numbers.