0
The code below output different results. Can anyone clarify me on that.
#include<iostream> using namespace std; int main() { int res; for(int flag = 0; flag < 5; flag++) { if((flag > 2) && (res > 2)) { res += 7; } } cout << res; return 0; }
3 Réponses
+ 3
In if condition your res variable is un-initilized that's why it taking default values and your if condition never be true and by using cout u printing value of res which is garbage
+ 5
I think you need to initialize "res" variable before you apply .
+ 4
Thanks much I get it