How many times does the following loop execute? What is the value of num after the execution?
int num-5:
do {
System.out.println("Hello world");
num - - ;
} while (num>2);
Answers
Answered by
2
I'll fix and then solve:-
here ,
int num=5; is correct .
now:-
loops will execute -->3
after execution num=>2
Attachments:
Answered by
4
Answer:
the loop is executed four times in which at fourth time it comes out of the loop as the condition is not satisfied .
and thus the num = 2
check the attachment for the complete answer..
hope this helps you.....
Attachments:
Similar questions