This is a challeng question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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💓😍
5 Answers
+ 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💓😍