Newbie Question: using Switch and Printf

From: ~neil~ (neilwrites2_at_hotmail.com)
Date: 07/31/04


Date: 31 Jul 2004 10:58:19 -0700

Hello

I've been learning C for over the last couple months ON MY OWN, and
I'm trying to solve this program.

How do you decode a number in each case in a switch from 0 to 9 which
will save the text of each number? EX. case 7: will output "seven" in
the Printf statement. Problem is it's in a loop, each number is
extracted from the user input(scanf statement) like 2057 % 10 will
extract the 7, then 5, then 0, then 2 in each pass of the loop. The
remaining number(s)like 205 after the extraction is put in a "int
variable" called "hold"

The program output looks like this:

Enter a number > 2057
The digits you entered:
Seven,Five,Zero,Two

press any key to continue........

I tried bringing out the text using #define ON "one".This is NOT
homework you guys! I have a book "Learning C Step By Step" by Jean
Paul Corriveau, which is the toughest program I've come accross so
far.I can extract each number in each case for the switch,
however I'm confused on what code to use in each case for the
output(printf)??

The while loop I construsted is infinite, I use CTRL-C to escape.
I suspect the progam uses character array(s) or strings, but I have
limited knowledge of "C"

If your wondering, I was going to take "C" at my college this year
starting in september,there are NO summer classes offered for this
course,it's $1250 bucks for 300 hours of in class instruction.

Any help with the code would be great?

Sincerely
~neil~



Relevant Pages

  • Re: Newbie Question: using Switch and Printf
    ... > I've been learning C for over the last couple months ON MY OWN, ... > the Printf statement. ... > far.I can extract each number in each case for the switch, ... > The while loop I construsted is infinite, ...
    (comp.lang.c)
  • Re: acceptance of forth
    ... immediate goals. ... I have always found that I need three books when learning a new ... can too easily be assumed to be the main purpose of the loop. ... if I had made a mistake ...
    (comp.lang.forth)
  • Re: acceptance of forth
    ... I think it's a matter of focus. ... In retrospect, you might have saved some time by learning on a friendlier system until you got the basics down, and then seeing how they apply in OF. ... can too easily be assumed to be the main purpose of the loop. ...
    (comp.lang.forth)
  • Re: Wisdom teeth
    ... Baylor, Baylor required $100,000.00 cash prior to admission *and* ... told me 60% of his collection came from Wizzy extraction, ... I think dentistry changed a long way in the last 10 years.......it is ... and I hope by doing my learning I can ...
    (sci.med.dentistry)
  • Re: Wondering where the best place is to LEARN to do forward lopp
    ... Which tack are you trying to learn to loop on? ... learning on starboard, bad if you're learning on port. ... you don't need much of a ramp to learn to loop. ... me) learned them in flat water jumping WAY off the wind. ...
    (rec.windsurfing)