== is a comparison operator. It is used in a conditional test. = is an assignment operator, it sets the value of a variable.
assignment operations do return values (the value being assigned), and, conditional tests simply test for a non-zero state, so, it is possible to write 'valid' code such as if (x = y) which will set x to y and return true if y is nonzero, as opposed to if (x == y), which will not set any values, but will return true if x and y are equal.
++ is an addition operator. For example, if you had an integer i, the following commands are equivalent.
c++
c = c + 1;
c += 1;
There is also the operator ++c. The difference between the two ++ operators is when the computation is done. If you do ++c, it will be done before a comparison, and c++ will be done after.
which is this program?
manorhacker 2 years ago
to clarify, c++ returns the value of c before being incremented. ++c returns the value of c after being incremented.
c = 3; d = c++; // now c is 4 and d is 3.
c = 3; d = ++c; // now c is 4 and d is also 4.
oldneuro 3 years ago
== is a comparison operator. It is used in a conditional test. = is an assignment operator, it sets the value of a variable.
assignment operations do return values (the value being assigned), and, conditional tests simply test for a non-zero state, so, it is possible to write 'valid' code such as if (x = y) which will set x to y and return true if y is nonzero, as opposed to if (x == y), which will not set any values, but will return true if x and y are equal.
oldneuro 3 years ago
never mind i found my problem
jtman54159 3 years ago
this program is not working for me
Is it my compiler maybe, I'm using code blocks 8.02
jtman54159 3 years ago
++ is an addition operator. For example, if you had an integer i, the following commands are equivalent.
c++
c = c + 1;
c += 1;
There is also the operator ++c. The difference between the two ++ operators is when the computation is done. If you do ++c, it will be done before a comparison, and c++ will be done after.
Chris15118 3 years ago
could you explain what ++ does and why you used == instead of =?
subwaybusker 3 years ago