Solved

Selection

Posted on 1997-02-18
3
228 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
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
rbr earned 100 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stack 22 166
mixing C++ and C code elegantly 10 157
why "." vs "->" 23 120
Windows 2012 R2 -- create 3.5TB GPT from unallocated space ? 1 33
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

803 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