4.02.2012

Identify case of character

Q. Write a C program to accept a character value form user and find out, character is capital letter or small letter.

Ans.

/*c program to find out entered character is capital or small letter*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char ch;
 printf("Enter any character : ");
 scanf("%ch", &ch);
 if(ch>='A' && ch<='Z')
    printf("You entered capital letter!");
 else if(ch>='a' && ch<='z')
    printf("You entered small letter!");
 else
    printf("You entered invalid character!");

 getch();
 return 0;
}

/****************Output*****************/

Screen shot for identify entered letter is capital or small


No comments:

Post a Comment