Why it is not working ? Please help . Thank you ☺️ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why it is not working ? Please help . Thank you ☺️

https://code.sololearn.com/c45d4DxgvL1t/?ref=app

7th Mar 2022, 7:19 PM
Abhay mishra
Abhay mishra - avatar
4 Answers
+ 3
Start loop from i=1 ; not from 0 (n/0= error) And increment count by 1 only,not by i. count=count +1
7th Mar 2022, 7:47 PM
Jayakrishna 🇮🇳
+ 4
I hope this link helps you https://code.sololearn.com/cn7bc0Uk3evY
7th Mar 2022, 9:21 PM
SoloProg
SoloProg - avatar
+ 3
Thank you sir ☺️
7th Mar 2022, 9:37 PM
Abhay mishra
Abhay mishra - avatar
+ 2
I am not sure why it isn’t working. I am not too familiar with C. But, let me tell you that right now your “count” isn’t really counting as I think you want it to count. If you do “count = count + i” you keep adding the i to it. I n = 4 when in the for loop i becomes 2, it evaluates as true 4%2=0 and it does count = count + 2. Then when it reaches i = 4 (because you use i is lower then or equal to n (4) ) it again evaluates as true because 4%4=0. i is now 4 and count is still 2. Count = 2 + 4 so count becomes 6 Edit: Perhaps you meant count++ instead
7th Mar 2022, 7:47 PM
Brave Tea
Brave Tea - avatar