check character or digit...

1.Write a program that asks the user to enter a character, and then determine whether the character is a digit or an alphabet. Some sample outputs of the program are shown below. You are prohibited from using isdigit() function or isalpha() function from the cctype header file. (Hint: This question tests your understanding of ASCII characters.)

Sample Program Output 1:
Enter a character: q
q is an alphabet.

Sample Program Output 2:
Enter a character: Z
Z is an alphabet.

Sample Program Output 3:
Enter a character: 9
9 is a digit.

2.Write a program that asks the user to enter an integer, and then determine the number of odd and even digits in the integer. Some sample outputs of the program are shown below.

Sample Program Output 1:
Enter an integer: 723819
There are 4 odd digits and 2 even digits.



Can someone help me to solve these 2 questions?
We won't do your homework... Nice try though....

Try by yourself... (RTFM)
i just wan to know how to check the string one by one?
by the way, it is not my homework.i just take from textbook for my practice.
Well, for #2, you can use a stringstream to convert the number to a string, and then parse through it.

For #1, I don't know what you are having difficulties with.
1. Catch the input in a string (or C-string).
2. Go through the string one-by-one with a for loop.

Or

1. Use a cin.get() loop.
Topic archived. No new replies allowed.