|
| ||||||||||||||||||||||||||||||||||||
| makan007 (77) | |||
I need to know is it better to declare static int goodAns = 1 or goodAns = 0? What is the diff? | |||
|
|
|||
| Bazzy (6258) | ||
It depends on what you need | ||
|
|
||
| screw (145) | |||
|
Hello! Ok, what don't you understand? The static keyword ensures that the variable preserves its value between function calling. http://www.learncpp.com/cpp-tutorial/811-static-member-variables/ The % operator divides the goodAns by 2 and return the fractional part. So 1 / 2 would be 0.5 but it will be made round to 0.
The goodAns++ instruction is always executed! It doesn't belong to the if statement. If you want it then you should use braces. | |||
|
Last edited on
|
|||