+ 2

This is a challeng question

int a=0; for(int i=0;i<=2;i++) a=a+i; cout <<a%2; I did not understand the concept of for loop please any one help me and i am not understanding how to solve it

31st Aug 2020, 2:33 AM
💓DORAEMON💓😍
6 Respostas
+ 2
First, a is initialized to 0, and the loop make i added to a 3 times, which are 0, 1, 2. 0(a)+0+1+2=3. 3%2==1.
31st Aug 2020, 9:22 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 2
Thank you AteFish
2nd Sep 2020, 5:11 AM
💓DORAEMON💓😍
+ 1
Your code will make compile errors. These are missing ; and Capital Cout. And if you resolve the compile error, it will introduce an infinite loop because i=2 always returns true.
31st Aug 2020, 3:10 AM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar
+ 1
Carrie Forle thankyou for giving reply and sorry for making mistakes here again i edited it once please check it
31st Aug 2020, 3:42 AM
💓DORAEMON💓😍
+ 1
Thank you a lot carrieForle
31st Aug 2020, 9:38 AM
💓DORAEMON💓😍