hi, I have this code:
#include<iostream>
#include<cstdio>
#include<sstream>
using namespace std;
int main (char argc)
{
float n1;
char operators;
string n2;
float n2_act;
float ans;
cin >> n1;
for(;;)
{
cin >> operators;
cin >> n2;
if(n2 == "k")
{
continue;
}
else
{
stringstream(n2) >> n2_act;
if(operators == '+')
{
n1 = n1 + n2;
}
}
}
cout << n1 << endl;
}
I don't get an answer when I enter 1+2+3 and when I put cout << n1 << endl; inside the for() loop, the answer comes out as 3. Any solutions?