0
Loop do ehile sum how to get answer
Get answer explanation
11 Réponses
+ 1
IT WILL DO THE SUM OF FIRST 10 NUMBERS USING DO WHILE LOOP
var sum = 0;
var number = 1;
do
{
sum += number;
number++;
}
while (number <= 10);
alert("Sum = " + sum);
0
Sum=0
Num=1
Do condition (sum+num)=1
While(1,2,3,4,5,6,7,8,9,10)
??🙄
0
Help me
0
you have to give condition in while not numbers.
0
This is the syntax
do
{
code block to be executed
}
while (condition);
0
Explain
0
var sum = 0;
var number = 1;
do
{
sum += number;
number++;
}
while (number <= 10);
alert("Sum = " + sum);
see in this there are to variable sum=0 and number=1
then inside the do statement there is operation like sum+=numbe( This will do
sum=sum+number. so result is 0+1=1 ).so 1 is stored in sum. After doind this it will increase value of number by doing number++(So it will become 2)after doing this it will check while condition tht the value of number is smaller than and equal to 10 if it is true then it will repeat same process. And this will continue till condition becomes false
0
Wait the last 2 line explain
0
Alert ("sum="+ sum);
Explain this command
0
alert command will open a dialogue box and show the answer of given input
0
Ok