+ 2

# Can someone give me some hints to make a program in c++ that solves expressions?

I'm just a beginner and i'm trying to make a program that solves expressions, but i can't figure out how. p.s. sorry for my poor english

16 Answers

+ 25

using functions overloading u can do it

+ 22

its tough in cpp as there +, -, *, /, (, ) are char type input and 3,7,5.0 are int and float type input
u can't mixed them together in a single variable

+ 22

may be using functions and stack

+ 21

cout<<3*(7-3)+12;
this will print the result simple
in this first brackets will solve, then multiplication and then addition

+ 21

u can also take one variable like a
and store the value of ur expression in it like
a=3*(7-3)+12; and then print it
cout <<a;

+ 21

go and check my code named
expression solver

+ 21

u want to insert the whole expression or want to insert the value for this expression

+ 20

write that expression here

+ 3

What expressions

+ 2

every expression is fine, you can use 3*(7-3)+12 for example

+ 1

math expressions

+ 1

wait, it doesn't work

+ 1

yea, but i have to be able to insert the expression

+ 1

i want a code that solves any expression

+ 1

there must be a way to solve any expression

+ 1

that's what I want to do