OK, so you've edited it to include some sort of instructions. We await the code tags.
In C++ (and most programming languages),
=
means assignment ("setting equal to") whereas
==
tests for equality ("is it the same value as?"). In your code (unlike your mathematics) you need
==
. Thus ...
if(a=b)
should be
if ( a == b )
When that is corrected, the same line in your code has a second error.
if ( a == b ) ;
has a semicolon at the end ... which means that the thing you anticipate doing if the condition is true ... stops at the end of the line (and would essentially do nothing). Accordingly,
cout << e;
would be done regardless of the test. So you should have
1 2 3 4
|
if ( a == b )
{
cout << c - b << '\n';
}
| |
For a one-line action the curly braces aren't essential. However, they will reduce the chance of you making an error here. You could also write
cout << e << '\n';
if e has been evaluated as c - b; however, if writing out its value is all you do with it then that isn't necessary.