85.0k views
3 votes
What is the value of variable num after the following code segment is executed?

var num = 10;

while ( num <10)
{

num = num +1;

}

User Davew
by
5.3k points

1 Answer

2 votes

Answer:

num=10

Step-by-step explanation:

Initial value of variable "num" is 10. When while loop execute for the first time,it checks the condition (num<10) and founds this FALSE. So the statement inside the while loop will not be executed. If while loop doesn't execute then it will not going to change the value of "num". That is why the value of "num" will remain same i.e. num=10.

User GanesH RahuL
by
5.6k points