Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
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” .
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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
Chapter 14 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 14.1 - What is a recursive functions base case?Ch. 14.1 - What happens if a recursive function does not...Ch. 14.1 - Prob. 14.3CPCh. 14.1 - What is the difference between direct and indirect...Ch. 14 - What type of recursive function do you think would...Ch. 14 - Which repetition approach is less efficient; a...Ch. 14 - When should you choose a recursive algorithm over...Ch. 14 - Prob. 4RQECh. 14 - Prob. 5RQECh. 14 - Prob. 6RQE
Ch. 14 - Predict the Output 7. What is the output of the...Ch. 14 - Soft Skills 8. Programming is communication; the...Ch. 14 - Prob. 1PCCh. 14 - Recursive Conversion Convert the following...Ch. 14 - Prob. 3PCCh. 14 - Recursive Array Sum Write a function that accepts...Ch. 14 - Prob. 5PCCh. 14 - Recursive Member Test Write a recursive Boolean...Ch. 14 - Prob. 7PCCh. 14 - Prob. 8PCCh. 14 - Ackermanns Function Ackermanns function is a...Ch. 14 - Prefix to Postfix Write a program that reads...Ch. 14 - Prob. 11PCCh. 14 - Prob. 12PC
Knowledge Booster
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
- 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. please i need the program in c or c++ and please read the requirement below Algorithm design: The required data structure is designed, the algorithm idea and algorithm steps are given, and the time complexity of the algorithm is analyzed. Annotated source code: Paste the source code, preferably annotate the code.…arrow_forwardExpression 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]1) You are required to use stack.2) 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. Please i need the above topic program in C or C++arrow_forwardDesign a function that accepts an integer argument and returns the sum of all the integers from 1up to the number passed as an argument. For example, if 50 is passed as an argument, thefunction will return the sum of 1, 2, 3, 4, . . . 50. Use recursion to calculate the sum.arrow_forward
- c++ A palindrome is a string that reads the same both forward and backward. For example, the string "madam" is a palindrome. Write a program that uses a recursive function to check whether a string is a palindrome. Your program must contain a value-returning recursive function that returns true if the string is a palindrome and false otherwise. Do not use any global variables; use the appropriate parameter.arrow_forwardWhen a function is executing, what happens when the end of the function block isreached?arrow_forward(Rounding Numbers) An application of function floor is rounding a value to the nearestinteger. The statementy = floor(x + .5);will round the number x to the nearest integer and assign the result to y. Write a program that readsseveral numbers and uses the preceding statement to round each of these numbers to the nearestinteger. For each number processed, print both the original number and the rounded number.arrow_forward
- code in C#. please code in simplest way.arrow_forward8.5 (Character Testing) Write a program that inputs a character from the keyboard and tests it With each of the functions in the character-handling library. The program should print the value returned by each function.arrow_forward*C Language The greatest common divisor of integers x and y is the largest integer that divides both x and y. Write a recursive function GCD that returns the greatest common divisor of x and y. The GCD of x and y is defined as follows: If y is equal to zero, then GCD(x, y) is x; otherwise GCD(x, y) is GCD(y, x % y) where % is the remainder operator.arrow_forward
- C++ assignment Write a C++ program that lets the user guess whether a randomly generated integer would be even or odd. The program randomly generates an inte- ger and divides it by 2. The integer is even if the remainder is 0, otherwise odd. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect.arrow_forwardComputer Science In scheme/racket Define a function display-all, which is a variation of the native function display. display-all takes one or more arguments and displays them. (display-all "foo") => "foo" (display-all "foo" "bar") => "foo" "bar"arrow_forwardDefine the function: int power (int base, int exp) {/*It accepts the arguments for base and exponent and returns power. The algorithm is to repeatedly multiply the value of the base to how many times the value of exponent. Test the function inside main(). Write the complete C program. */} For example: Intput. Result 2 32 5arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
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