Thursday 26 January 2012

Write a program in c to accept any character and check whether the given character is capital or small

#include<stdio.h>
#include<conio.h>
int main( )
{
char ch;
clrscr( );
printf("Enter the any alphabet:");
scanf("%c ", &ch);
if(ch>= 65 && ch<=90) // or if(ch>='A' && ch<='Z')
printf("\nGiven Alphabet is in Upper case");
else
printf("\nGiven Alphabet is in Lower case");
getch( );
return 0;
}

Output:- Enter the any alphabet: A
Given Alphabet is in Upper case

Note :- ASCII value of 'A'=65 and 'Z'= 90

No comments:

Post a Comment