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

Write a program to check if a number is prime or not.

Write a program to print the grades to a student.

write a program (keep taking numbers as input from user until user enters an Odd number)