| | |
C program to test case of character
![]() |
•
•
Join Date: Jun 2009
Posts: 28
Reputation:
Solved Threads: 0
I want to write a C program to test whether the character is uppercase, lowercase, digit or special symbol.
My question how to print whether the character is a special symbol. I don't know this. Please can anyone point out.
Thanks
c Syntax (Toggle Plain Text)
void main () { char ch; printf("\n Enter any character from the keyborad"); scanf("%c",&ch); if (ch>=65&&ch<=90) printf(" \n the character is uppercase); if(ch>=91&&ch>=122) printf(" \n the character is lowercase); if(ch>=48&&ch<=57) printf("\n You entered a digit ); }
My question how to print whether the character is a special symbol. I don't know this. Please can anyone point out.
Thanks
Last edited by WaltP; 31 Days Ago at 3:11 am. Reason: Added CODE tags -- with all the help about them, how could you miss using them????
•
•
Join Date: Sep 2009
Posts: 18
Reputation:
Solved Threads: 1
0
#2 32 Days Ago
Since you are able to test for the first three, i think an else condition will be able to give you the fourth case, i.e a special character. Use your program to try this algorithm
hope it works!
Regards
C Syntax (Toggle Plain Text)
if(element_is_a_lowercase) print("lowercase") else if(element_is_an_uppercase) print("uppercase") else if(element_is_a_digit) print("digit") else print("is special")
Regards
Last edited by SecurExpert; 32 Days Ago at 3:14 am.
•
•
Join Date: Jun 2009
Posts: 28
Reputation:
Solved Threads: 0
•
•
•
•
Since you are able to test for the first three, i think an else condition will be able to give you the fourth case, i.e a special character. Use your program to try this algorithm
hope it works!C Syntax (Toggle Plain Text)
if(element_is_a_lowercase) print("lowercase") else if(element_is_an_uppercase) print("uppercase") else if(element_is_a_digit) print("digit") else print("is special")
Regards
Thanks for this explanation. I would like to ask
1. Whether I can use ASCII code for to print special symbols, like I have done above in 3 cases. If so, would you please tell the codes.
2. Are there braces missing in my program after if statement.
3. Can I test this program online.
Thanks
0
#4 32 Days Ago
•
•
•
•
I want to write a C program to test whether the character is uppercase, lowercase, digit or special symbol.
void main ()
{
char ch;
printf("\n Enter any character from the keyborad");
scanf("%c",&ch);
if (ch>=65&&ch<=90)
printf(" \n the character is uppercase);
if(ch>=91&&ch>=122)
printf(" \n the character is lowercase);
if(ch>=48&&ch<=57)
printf("\n You entered a digit );
}
My question how to print whether the character is a special symbol. I don't know this. Please can anyone point out.
Thanks
Manic twiddler of bits
0
#5 32 Days Ago
•
•
•
•
1. Whether I can use ASCII code for to print special symbols, like I have done above in 3 cases.
•
•
•
•
2. Are there braces missing in my program after if statement.

•
•
•
•
3. Can I test this program online.
•
•
•
•
This code is specific to the ASCII character set. It would not work with other character sets.
For readability I would use character constants instead of straight values:
C Syntax (Toggle Plain Text)
if (ch >= 'A' && ch <= 'Z') { printf("The character is uppercase\n"); } else if (ch >= 'a' && ch >= 'z') { printf("The character is lowercase\n"); } else if (ch >= '0' && ch <= '9') { printf("You entered a digit\n"); }
-Tommy (For Great Justice!) Gunn
![]() |
Similar Threads
- file program changing case (C)
- Test Casing (C++)
- Character Processing and use of Functions (C++)
- JUnit test case problem. (Java)
- Case Changing Program - Need help on last bit (C++)
- help regarding automated test case generation tool (Java)
- reading a file into code (Java)
- File parsing in 'C' (C)
Other Threads in the C Forum
- Previous Thread: Guide to proper code tagging using pictures.
- Next Thread: lowest form of rational numbers
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h





