0

Loop do ehile sum how to get answer

Get answer explanation

28th Oct 2020, 7:26 AM
Vashnavi Ruthra
Vashnavi Ruthra - avatar
11 Respuestas
+ 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);
28th Oct 2020, 8:43 AM
Rudresh
Rudresh  - avatar
0
Sum=0 Num=1 Do condition (sum+num)=1 While(1,2,3,4,5,6,7,8,9,10) ??🙄
28th Oct 2020, 8:59 AM
Vashnavi Ruthra
Vashnavi Ruthra - avatar
0
Help me
28th Oct 2020, 8:59 AM
Vashnavi Ruthra
Vashnavi Ruthra - avatar
0
you have to give condition in while not numbers.
28th Oct 2020, 9:00 AM
Rudresh
Rudresh  - avatar
0
This is the syntax do { code block to be executed } while (condition);
28th Oct 2020, 9:02 AM
Rudresh
Rudresh  - avatar
0
Explain
28th Oct 2020, 9:08 AM
Vashnavi Ruthra
Vashnavi Ruthra - avatar
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
28th Oct 2020, 9:26 AM
Rudresh
Rudresh  - avatar
0
Wait the last 2 line explain
28th Oct 2020, 12:29 PM
Vashnavi Ruthra
Vashnavi Ruthra - avatar
0
Alert ("sum="+ sum); Explain this command
28th Oct 2020, 12:31 PM
Vashnavi Ruthra
Vashnavi Ruthra - avatar
0
alert command will open a dialogue box and show the answer of given input
29th Oct 2020, 4:22 AM
Rudresh
Rudresh  - avatar
0
Ok
29th Oct 2020, 6:23 AM
Vashnavi Ruthra
Vashnavi Ruthra - avatar