Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Selection

Posted on 1997-02-18
3
Medium Priority
?
255 Views
Last Modified: 2010-04-15
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)
0
Comment
Question by:leekoon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
rbr earned 300 total points
ID: 1249503
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


0
 

Author Comment

by:leekoon
ID: 1249504
Edited text of question
0
 
LVL 10

Expert Comment

by:rbr
ID: 1249505
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question