Prime Sieve Doubts

Why we have marked prime[1] = prime[0] = 0, as they both are not prime, so they should be marked as 1 but it is not so, please explain? Secondly, why in csum array, in which we are computing number of primes, why we adding only prime[1] in every iteration.
Thirdly, we are finding number of prime numbers in range of a to b, so why we are doing csum[b]-csum[a-1] and not csum[b]-csum[a], please explain.

Hello @Sakshi2004 i have checked your code and you are doing in the opposite way i.e you have to take either all the numbers before as 0 and then mark all the even numbers as 0 and then for all odd number you have to check for that i am correcting your code:
and we are marking prime[1] = prime[0] = 0 them as non prime only its just you are doing in the other way round.
second query we are counting the number of primes till at anypoint so thats why in the csum array we are making the array incrementing by the previous result stored as 1.
and thirdly in array we have zero based indexing that is why we have done this: csum[b]-csum[a-1]

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.