+ 2
What is wrong in following loop? while(p<=100) sum+=p*p
while loop
4 Respuestas
+ 7
int p = 1, sum = 0;
while(p <= 100) {
sum += p * p;
p++;
}
+ 4
p isn't incremented in the loop so p can't never be equal to 100!
+ 4
variables p and sum are not initialized, lost semicolons after p * p. there is no loop exit condition, because p does not change
+ 3
p does not change is value so it becomes an infinite loop, the condition is always true