We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

# Selection

on
Medium Priority
270 Views
Write a program that takes an integer keyed in from the terminal and extracts and displays each digit of the integer in English. For example if the user type in 780, Seven Eight Zero will be displayed on the screen.(Without using pointers)
Comment
Watch Question

## View Solution Only

Commented:
Try this programm:
#include <stdio.h>
int main(int argb, char *argv[])
{
unsigned number;
char buffer[100];
int i;

scanf ("%u", &number);
sprintf (buffer, "%u", number);
for (i=0;i<strlen(buffer);i++) {
switch (buffer[i]) {
case '0':
printf ("Zero ");
break;
case '1':
printf ("One ");
break;
case '2':
printf ("Two ");
break;
case '3':
printf ("Three ");
break;
case '4':
printf ("Four ");
break;
case '5':
printf ("Five ");
break;
case '6':
printf ("Six ");
break;
case '7':
printf ("Seven ");
break;
case '8':
printf ("Eight ");
break;
case '9':
printf ("Nine ");
break;
}
}
printf ("\n");
return 0;

}

If you want to parse longer integer numbers just read it directly in the buffer by using scanf ("%s",buffer);

Robert B. Rossmann

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
Edited text of question

Commented:
Where do I use pointers? The only pointer I need is in the scanf function and there you must use a pointer.

Please explain me exactly what you want.

Robert B. Rossmann
##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile