why this line is causing error… the expression sqrt(n) will be calculated just once right?
in python (2nd link) it doesn’t raise any error !
Doubt in for loop
hello @prerak_semwal

here u r dividing n by 0 (i=0 in starting) thats why it is giving arithmetic expection error.
…
bro why will it excute? it will stop at the first step only becuase u are diving a number by 0. because of which the system will throw exception
in python u are starting from 1 onwards but here it is from 0.
use <=
…
…
…
…
use while loop in python if u want similar behaviour.
in python the start and end of iteration get decided at the beginning of first iteration itself after that it does not change(evidentn from the value of i itself).
what do you mean by above ?
So in c++ at every iteration the ending condition is re-computed right? and then the variable i is updated (i++)
…
yeah …the condition get reevaluated after every iteration in c++.
i am saying by looking at the value of i , we can say that division of n has no impact on number of iteration