Questions tagged [rpn]

For questions relating to the Reverse Polish Notation, which is a notation for mathematical expressions where the operands precede the operator.

In computing, RPN is ideally suited for a stack-based implementation, and in hardware it has a long history with HP hand-held calculators.

E.g. 1 2 + means apply the + operator to the operands 1 and 2.

198 questions
-1
votes
1 answer

A program which evaluates a mathematical expression by first converting it into RPN and evaluating the result using precedence of operators

#include char infix[200]; char stack[200]; char queue[200]; int count_stack = 0; int count_queue = 0; int precedence(char x) { switch (x) { case '^': return 2; case '/': return 1; case '*': …
Geek
  • 7
  • 2
-1
votes
1 answer

Swift differentiate Clear (C) and All clear (AC)

Hello I am a beginner and I am building a RPN calculator. all my operations are effectuated in a separated viewcontroller called calcengine. I have some code for the AC and I have two questions: @IBAction func AllClear(sender: UIButton) { …
kepi
  • 377
  • 1
  • 3
  • 7
-1
votes
1 answer

How would I add values since they are strings?

I have already tried using atoi then switching them back to strings to push, I am trying to make a rpn calculator for class so the push, pop, seek, and stack structure are how then need to be but I cant get it to add the integer values. #include…
-1
votes
2 answers

Reverse Polish Notation in C

I need help implementing my code. Here is the code in C. My assignment is to create a program for reverse polish notation. Here is what I have so far. One error i have right off is "control may reach end of non void function". After the error I'm…
justjoe
  • 11
  • 1
  • 2
-1
votes
1 answer

Ruby returning integer-only when item is in an array

I'm creating a reverse polish notation calculator as a 'warm-up test' for school. I've almost nailed it. The issue I'm coming across is when I run this myself, I see just the integer returned (which is desired). When I plug this into the school's…
CJ Johnson
  • 1,081
  • 9
  • 13
-1
votes
3 answers

C++ RPN calculator using an int stack

I am trying to write a RPN calculator in which this line of input for a simple example: 2 3 + would print: 5 and then end. I need the program to take the line of input, put the numbers on the stack, find non-numbers, check if they are operators:…
-2
votes
1 answer

How to convert into RPN(Reverse Polish notation) in Scala?

I tried to convert formula to RPN(Reverse Polish Notation) in Scala. RPN: https://en.wikipedia.org/wiki/Reverse_Polish_notation But I couldn't write any code. object RPNCalclator { def convertToRPN(expr: String): String = { ??? } def…
Hiromu Masuda
  • 259
  • 1
  • 3
  • 14
-2
votes
1 answer

Reverse Polish Notation Calculator in C++

I'm trying to code the RPN algorithm in C++, using a string as parameter. I'm using a stack and a string to be read. I know how the algorithm works, but I don't get a correct result, I always get 0. This is my code: #include #include…
DDN
  • 123
  • 1
  • 7
-2
votes
1 answer

RPN calculator (Swift xcode) - sine, cosine, tangent, reciprocal (1/x), log (base) functions

I have build a basic RPN calculator with Swift and I need to add those functions: sine, cosine, tangent, reciprocal (1/x), log (base) & log (base10). Here is the code that I have for the basic operations: import Foundation import UIKit class…
kepi
  • 377
  • 1
  • 3
  • 7
-2
votes
2 answers

String index out of range when accessing chars in a String

I'm trying to make an RPN calculator. I have done the conversion from infix to postfix, now I want to evaluate the converted expression. When I enter any expression I get error String index out of range: 1. Here's my code with what I'm supposed…
-2
votes
3 answers

Reverse Polish Notation with a Single Variable

I've already written code that can perform the following conversions to an input string 3(7x-1)+10x-4+3x=90x+1 (3*(7x-1)+10x-4+3x)-(90x+1) 37x1-*10x+4-3x+90x1+- But now, I'm a little stuck with this last one. I know how to write the code to solve…
jonbon
  • 1,142
  • 3
  • 12
  • 37
-2
votes
1 answer

Reverse Polish Notation in Haskell

I need to write a function that takes an arithmetic expression and converts it to a string in Reverse Polish notation using Haskell. Creating a function to evaluate an RPN expression is quite easy and need not to worry about, it's only the…
lehal475
  • 1
  • 2
-2
votes
5 answers

Datatype to store integers and arithmetic operators?

Is there any way that I can take input of numbers from users and also any arithmetic operator on a user choice when user wants to enter. I am basically trying to make a sort of calculator in which user will first enter numbers and in last the…
-3
votes
1 answer

Where has the first element of my array come from, and what is it?

I am writing a code to produce a C programmed RPN calculator using command line arguments. I am having an issue with the first calculation to be done by the program, as the first element in my array of operators is unknown to me and affects the…
-3
votes
3 answers

float addition 2.5 + 2.5 = 4.0? RPN

The code below is my subprogram to do reverse polish notation calculations... basically +, -, *, and /. Everything works in the program except when I try to add 2.5 and 2.5 the program gives me 4.0... I think I have an idea why, but I'm not sure how…
tkd_aj
  • 993
  • 1
  • 9
  • 16
1 2 3
13
14