+ 2
Why it is not working ? Please help . Thank you âșïž
5 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
+ 4
I hope this link helps you
https://code.sololearn.com/cn7bc0Uk3evY
+ 3
Thank you sir âșïž
+ 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