Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Videos

Question
Book Icon
Chapter 14, Problem 11PC
Program Plan Intro

Prefix to Infix

Program Plan:

  • Include required header files.
  • Give function prototype “prefix_To_Infix ()”.
  • Define the function “main ()”. Inside this function,
    • Declare a string variable “prefixStr”.
    • Get the prefix string from the user and store it in a variable “prefixStr”.
    • Do until the length of the string is equal to 0 using “while” loop.
      • Create an object “isStream” for input file stream.
      • Call the function “prefix_To_Infix ()” by passing the object “isStream” as the argument.
      • Get another prefix string from the user.
    • Return the statement.
  • Give function definition for “prefix_To_Infix ()”.
    • Get the first character and store it in a variable “ch”.
    • Do until the variable “ch” detects a space using “while” loop.
      • Get a character using “get ()” function.
      • Get the first character using “peek ()” function.
    • Check if the character is a digit.
      • Declare a variable “num”.
      • Create an object “ostr” from output string stream.
      • Get and print the number.
      • Return the object.
    • Else,
      • Get the character using “get ()” function and store it in a variable “ch”.
      • Call the function “prefix_To_Infix ()” and store the returned expression in a string variable “expr1”.
      • Call the function “prefix_To_Infix ()” and store the returned expression in a string variable “expr2”.
      • Check if the character is not any mathematical symbol like “+”, “-”, “*” and “/”.
        • Exit.
      • Return “expr1”, “ch”, and “expr2” .

Blurred answer
Students have asked these similar questions
C Program Pass-by-reference in Functions Using Pointers Write a function swap that swaps the values of three integers x,y, and z. x is swapped to y, then y to z, and lastly z to x. In the main function, write a program that ask for theee integer inputs and pass in the reference of those variables by calling swap function. more details below the photo.
(Variable-Length Argument List: Calculating Products) Write a program that calculates theproduct of a series of integers that are passed to function product using a variable-length argumentlist. Test your function with several calls, each with a different number of arguments.
Expression Conversion [Problem Description] Design a program which can tansfer an infix expression into a postfix expression and compute its result. Suppose the infix expression only includes’ *’, ‘/’, ‘+’, ‘-‘, ‘(‘, ‘)’ and the numbers are all integers. [Basic Requirements] You are required to use stack. The infix expression is inputted from keyboard as a string. If the input is legal, please convert the infix expression into postfix expression, calculate the result, and finally output the postfix expression and its value. If the infix expression entered is illegal, the program can prompt the user to input incorrectly and prompt the user to re-enter. If the input is do the code in c++ please
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++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License