Cant solve this C prob plz help

This is a discussion on Cant solve this C prob plz help within the C Programming forums, part of the General Programming Boards category; Hello everyone, Following is the problem as given in the "Programming in C" book in Chapter 6, Pg.94 Code: Write ...

1. Cant solve this C prob plz help

Hello everyone,

Following is the problem as given in the "Programming in C" book in Chapter 6, Pg.94

Code:
```Write a program that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English. So, if the user types in 932, the program should display

nine three two

Remember to display “zero” if the user types in just a 0. (Note: This exercise is a hard one!)```
I was able to reach the basic statements but couldnt go further when logic came into the picture.

Code:
```#include <stdio.h>
#include <conio.h>

int main ()

{

int number ;

clrscr () ;

printf ("Enter number\n\n") ;

scanf ("%d", &number) ;```
I strongly feel that if statements are gonna be used in this case

Plz help

2. if:

Code:
```char words[][]={
{"zero"},
{"one"},
{"two"},
};```
and the digits were say: 120

could the digits match up with the index for the right word of a row in the words[row][] array?

That is, words[0] equals "zero", words[1] row equals "one", etc.

3. Main problem is: given an integer, how to peel off digits. A sequence of divide-by-10 to extract the units digit... Or another way would be to convert the integer to a string of digits. Then loop through from the beginning and index into a word array like Adak suggested.

4. Originally Posted by nonoob
Main problem is: given an integer, how to peel off digits. A sequence of divide-by-10 to extract the units digit... Or another way would be to convert the integer to a string of digits. Then loop through from the beginning and index into a word array like Adak suggested.

Oh, how come the author has asked an Array question when Arrays start from chapter 7!!! Thats strange....Nevertheless I would highly recommend this book for learning C from scratch... Thanks alot for helping

5. Originally Posted by exus69
Oh, how come the author has asked an Array question when Arrays start from chapter 7!!!
Because there are other ways to do it (e.g. if/else like you mentioned or switch/case). Then chapter 7 comes along and says, "But wait! Look at this (easier) way of doing it!"