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.




#include<stdio.h>
main()
{
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

4 comments:

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=");
Scanf("%c"&ch");
if(ch>=65&&ch<=90)
Ch=ch+32;
Printf("it is upper case");
else
Printf("it is lower case");
return 0;
}