+ 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

4th Jan 2021, 1:57 PM
Aman Rana
Aman Rana - avatar
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
4th Jan 2021, 2:05 PM
noteve
noteve - avatar
0
Thanks bro got it
4th Jan 2021, 6:58 PM
Aman Rana
Aman Rana - avatar