Subscribe

RSS Feed (xml)

Saturday, October 3, 2009

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

// Method 1: Without Library functions
//using ASCII values

#include(stdio.h) //note use '<' & '>' in place of '(' & ')'
#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

2 comments: