Question: 1. What is the value of variable num after the following code segment? var num = 10; while ( num > 0 ) { num
1.
What is the value of variable num after the following code segment?
var num = 10;
while ( num > 0 ) {
num = num -1;
}
2.
What is the value of variable num after the following code segment is executed?
var num = 1;
while ( num >10 ) {
num = num -1;
}
3.
What is the sum of roll1 and roll2 after the following code is executed?
var roll1=0; var roll2=0;
while ( roll1+roll2!=6 ) {
roll1=Math.floor(Math.random( )*6+1);
roll2=Math.floor(Math.random( )*6+1);
}
4.Compare and contrast a while statement and an if statement ?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
