?
Solved

Selection

Posted on 1997-02-18
3
Medium Priority
?
249 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

770 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