+ 1
Using while loop calculate the sum, square and square root of even numbers ranging from 1-100
2 Respuestas
+ 2
var s=0,i=0;
while(i!=100)
{
s+=Math.sqrt(i);
// for power use Math.pow(i,2) function
i+=2;
}
remember this is not a copy past solution. You have to write rest of the code. I am sure you can it is easy
+ 1
Declare an index i for your while loop and assign 2. Declare another variable sum.
Then declare your while loop with the condition that i is less than 101. Everytime you go into your while loop. You add your current index i to sum and print i*i and the squareroot of i. At the end, after your while loop print sum.