Friday, July 14, 2006

[2/2] Detection of Character using ASCII (Conditional Operator)

The only difference between the previous program and this one is the use of Conditional Operator (:) instead of the Logical Operators.

Using conditional operators determine:

1) Whether the character entered through the keyboard is a lower case alphabet or not.
2) Whether a character entered through the keyboard is a special symbol or not.

char charac;

printf("Enter the character to be detected:");
scanf("%c", &charac);

((charac>=97) && (charac<=122))?(printf("\nLower Case")):(printf("\nNot a Lower Case character"));

/*For detection of Special Symbols*/

(((charac>=0) && (charac<=47)) || ((charac>=58) && (charac<=64))|| ((charac>=91) && (charac<=96))|| ((charac>=123) && (charac<=127)))? (printf("\nSpecial Symbol")):(printf("\nNot a Special Symbol"));


The file can be downloaded at:
Download File


vickey said...

its very usefull thanks

harisha said...

Sir. how can we do this program without using operator ?: sir please help me.

harisha said...

sir can you please tell me how to do this program without using conditional operator ?:

Ali Muaz said...

void main()
Char ch;
Printf("Enter any character=");
Printf("it is upper case");
Printf("it is lower case");
return 0;