Assignment inmost computer languages goes from right to left, so I *think* what you want to write is:
c = a + b
This takes the value of b, adds it to a, and then assigns that result to c.
not
a + b = c
The last operation, as you wrote it, assigned the value of c to b, adds that value to a, then looks for a place to put the result, which you have not given, because the operation comes to sa screeching halt after the "a"
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get the error message: 'non-lvalue in assignment' on lines
27,34,41,48. Here is the source code:
#include <iostream>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char op;
float a;
float b;
float c;
cout<<"SimpleCalc"<<endl<<endl;
cout<<"syntax: 1+2"<<endl;
cout<<"Commands:"<<endl;
cout<<"+: a+b"<<endl;
cout<<"-: a-b"<<endl;
cout<<"/: a/b"<<endl;
cout<<"*: a*b"<<endl<<endl;
cout<<"Operation>> "; //The operation you want to preform
cin>>op;
cout<<"First Number>> ";
cin>>a;
cout<<"Second Number>> ";
cin>>b;
if(op=='+')
{
a+b=c;
cout<<"Result: "<<c;
}
else
{
if(op=='-')
{
a-b=c;
cout<<"Result: "<<c;
}
else
{
if(op=='/')
{
a/b=c;
cout<<"Result: "<<c;
}
else
{
if(op=='*')
{
a*b=c;
cout<<"Result: "<<c;
}
}
}
}
system("PAUSE");
return 0;
}
Assignment inmost computer languages goes from right to left, so I *think* what you want to write is:
c = a + b
This takes the value of b, adds it to a, and then assigns that result to c.
not
a + b = c
The last operation, as you wrote it, assigned the value of c to b, adds that value to a, then looks for a place to put the result, which you have not given, because the operation comes to sa screeching halt after the "a"
Wayne
Thanks.
In my best southern fired accent - "use welcome!
We aim's to please....or kill, as the case calls"
Wayne