Welcome to the board. It's best to read the posts at the top, which cover the FAQ, how to use code tags, and the general rules, if you haven't done so. (It looks like you did some at least, you actually used code tags, which is more than most.)
You should next post your attempt at the code, and where you're having problems. From your post, I'm just guessing that you're having problems with the way a switch works.
Do you know how a switch works? If not, I'll show you real quick:
Code:
switch( some_integer )
{
case some_integer_value:
one_or_more_statments;
break; /* optional, required if you don't want cascading cases. You don't in your example */
case another_value:
...repeat...
}
In your case, you'll want to be passing it a single digit. Thus, you'll need a total of 11 statements. (You'll want one for each single digit numerical value, and one for the default one, which will be your error message if they pass something other than 0 through 9.)
If you don't know how to pass variables by value to functions, it goes something like this:
Code:
void myfunction( int argument )
{
...do stuff with argument...
}
... stuff ...
int x = 4;
myfunction( x ); /* valid */
myfunction( 9 ); /* valid */
myfunction( 4.5 ); /* not valid, not an int */
myfunction( 'a' ); /* valid, the value of 'a' evaluates to an integer */
Have fun.
Quzah.