answersLogoWhite

0


Best Answer

To solve this you need to remember that chars in C are represented as ints. Because of this property, you can use int comparison operators:

// to test if character c is a letter

int is_alpha(const char c) {

if( c >= 'a' && c <= 'z' )

return 1;

if( c >= 'A' && c <= 'Z' )

return 1;

return 0;

}

// to test if character c is a digit

int is_digit(const char c) {

if( c >= '0' && c <= '9' )

return 1;

return 0;

}

To test for a "special character" you would probably do best writing a similar function which checks for other ASCII value ranges.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago




1. Get the input- one character from the user
scanf("%c",&ch);
2. check

if((ch>=65)&&(ch<=90))
then print the Character as Upper Case Alphabet

if((ch>=97) &&(ch<=122))
then print the character as Lower Case Alphabet

if((ch>=48) && (ch<=57))
then Numeric

if(((ch>=0)&&(ch<=47))((ch>=58)&&(ch<=64))(ch>=91)&&(ch<=96))(ch>=123)&&(ch<=127)))
then print the character as Special Symbol

3.Terminate the program.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Check whether a character is alphabaticdigital or special character using C program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program to initialize a character and print whether it is uppercase lowercase or special character in java module 1?

I'll just write a function to do that, I hope the good people won't try to run it as it is.... void function() { char c = 'a'; if( c &gt;= 'a' &amp;&amp; c &lt;='z' ) System.out.println("LowerCase"); else if( c&gt;='A' &amp;&amp; c &lt;='Z' ) System.out.println("UpperCase"); else System.out.println("Special Character"); }


Write a C program to find out whether character passes through keybroad is a digit or not?

hey..it s simple..make use of built-in function isdigit(character)..it s in stdlib.h...


WAP to initialize a character and print whether it is upper caselower case or special character without using logical operators?

The general solution to this problem is very simple to lay out, but part of it relies on what a "special character" is. The part of code which handles this will be highlighted for the reader to implement as he/she will. void displayType(char c) { if(Character.isUpperCase(c)) { // upper case System.out.println("Upper case"); }else if(Character.isLowerCase(c)) { // lower case System.out.println("Lower case"); } else { // special case // This is where the "special character" part comes in. // You may be defining a "special character" as any non-letter character, // in which case you can simple put the line to print it out in this else // block. A "special character" may also be any non-letter, non-digit // character, and so we would need to check for Character.isDigit at // this point. } }


Is shame a sign of your character?

No. It shows character whether you can get past it.


What is program icon appears regardless of whether the program is open?

pinned


An insurance carrier whether a private or a government program is referred to as a what?

An insurance carrier, whether a private carrier or a government program, is referred to as


How you would you write a program in turbo c7 if letter is vowel or consonant?

You can write a program in Turbo C7 that takes a character as input and checks whether it is a vowel or a consonant by using a simple if-else statement. You can compare the input character with a list of vowels (a, e, i, o, u) and if it matches any of these, then it's a vowel; otherwise, it's a consonant. Print the result accordingly.


What are the explanation steps for palindrome program?

If you want to check whether a string is a palindrome, you can reverse the string (for example, the Java class StringBuffer has a reverse() method), and then compare whether the two strings - the original string and the reverted string - are equal. Alternately, you could write a loop that checks whether the first character of the string is equal to the last one, the second is equal to the second-last one, etc.; that is, you have a counter variable (in a "for" loop) that goes from zero to length - 1 (call it "i"), and compare character #i with character #(length-i-1) inside the loop.


What question drives the need for reform in the welfare program?

Whether or not the welfare program is doing its job and not being abused are questions that drives the need for reform. Also, Whether or not the program is successful in helping individuals no longer be dependent on them.


Can you say Whether he was duplicitious regarding his character is open to question or would you have to word it differently?

The sentence "Whether he was duplicitous regarding his character is open to question" is grammatically correct and complete.


Write a program to adentify whether a character entered by a user is a vowel or a consonant?

You can check the value of a character by using if statements.Also, note that this code does not check for capital letters./* code */#include int main(){char c;c = getc(stdin);if (c 'o') {/* If the character is a vowel, this code will be executed. */} else if (c >= 'a' && c


How does computer know whether an instruction you typed is a program?

its nice