hello! i am in a beginniers comp sci class and i am trying to write a program where the user can enter an algebraic expression using +, -, and * only (ex. a+b*c), ask what the values of the variables are, and evalute the expression. it was suggested to turn the expression into an array and go from there. here is what i have so far:
<code>
#include <iostream>
#include <string>
using namespace std;
void main(void)
{
int i;
int value[16];
char expression[16]; // The expression we're going to figure out
cout << "Please enter an algebraic expression using only '+,' '-,', and '*,' with NO spaces." << endl;
cin >> expression;
for(i=0; i <= 15; i++)
{
if((expression[i]==!"+") || (expression[i]==!"-") || (expression[i]==!"*"))
{
cout << "What is the value for " << expression[i] << "?" << endl;
cin >> value[i];
}
}
cout << value;
}
</code>
the problem i am having is putting the operators into the value array since they are not integers. are there any suggestions of how to get through this? we just finished structs, and i do not have any background besides what i have learned in class.