EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
bartleby

Concept explainers

Question
Book Icon
Chapter 4, Problem 2PA
Program Plan Intro

Program to convert a decimal number into any base between “2” and “9”:

Program Plan:

  • In “main()” function
    • Declare variables “stackk1” for stack, “base_to” for base to which convert and “numm” for number in decimal to be convert.
    • Read values for “base_to” and “numm” from user.
    • If base is between “2” and “9” and “numm” is greater than “0”,
      • Push the value of “numm” mod “base_to” into stack “stackk1”.
      • Then Divide “numm” by “base_to” and take this value as next “numm”.
      • Continue above two steps till “numm” becomes “0”.
    • Pop all numbers from “stackk1” and print it till “stackk1” becomes empty.
    • If base is not between “2” and “9”, print error message.

Program Plan Intro

Modified program to convert a decimal number into any base between “11” and “27”:

Program Plan:

  • In “main()” function
    • Declare variables “stackk1” for stack, “base_to” for base to which convert and “numm” for number in decimal to be convert.
    • Read values for “base_to” and “numm” from user.
    • If base is between “11” and “27” and “numm” is greater than “0”,
      • Push the value of “numm” mod “base_to” into stack “stackk1”.
      • Then Divide “numm” by “base_to” and take this value as next “numm”.
      • Continue above two steps till “numm” becomes “0”.
    • Pop each number “ele” from “stackk1”
      • If “ele” is less than or equal to “9”, print itself.
      • If “ele” is greater than “9” and less than “27”, print character corresponding to ASCII value of “ele+55”
    • If base is not between “11” and “27”, print error message.

Blurred answer
Students have asked these similar questions
Suppose your computer is responding very slowly to information requests from the Internet. You observe that your network gateway shows high levels of network activity even though you have closed your e-mail client, Web browser, and all other programs that access the Internet. What types of malwares could cause such symptoms? What steps can you take to check whether malware has gained access to your system? What tools can you use at each step? If you identify malware, what ways might it have entered your system? How can you restore your PC to safe operation, including the special software tools you may use?
R language
Using R language
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning