Tuesday, 17 March 2015

To find a character is no./letter/special character Using C

# include <stdio.h>
# include <conio.h>

void main()
{
char ch ;
clrscr() ;
printf("Enter a charatcer : ") ;
scanf("%c", &ch) ;
if (ch >= 65 && ch <= 90)
printf("\nEntered character is a upper case letter") ;
else if(ch >= 97 && ch <= 122)
printf("\nEntered character is a lower case letter") ;
else if(ch >= 48 && ch <= 57)
printf("\nEntered character is a number") ;
else
printf("\nEntered character is a special character") ;
getch() ;
}

RUN 1 :
~~~~~~~
Enter a charatcer : b
Entered character is a lower case letter
RUN 2 :
~~~~~~~
Enter a charatcer : V
Entered character is a upper case letter
RUN 3 :
~~~~~~~
Enter a charatcer : 2
Entered character is a number
RUN 4 :
~~~~~~~
Enter a charatcer : #
Entered character is a special character

No comments:

Post a Comment