+ 1
I am using a for loop in c++ and defined a integer k.I am adding something to k but after each iteration its value resets to 0.
I am using a for loop in c++ and defined a integer k.I am subtracting something from k but after each iteration its value resets to 0.what should I do? For(int i=0;i<4:i++) { If(a[i]=='0') k=8-mid;\\where mid is some value } Cout<<k; After each iteration its value is resetting and I am not able to get the answer.PLS HELP
2 odpowiedzi
+ 3
Is this what you're trying to do?
Btw the reason it still 0 is because you are not incrementing the value of k but rather assigning new values to it every iteration.
https://code.sololearn.com/cak8r58Vhf9m/?ref=app
0
Thanks bro got it