int p=20;
while(p>10)
{
p - = 1;
System.out.print(p);
}
Answers
Answered by
5
Required Answer:-
Given C∅de:
int p = 20;
while (p > 10) {
p -= 1;
System.out.print(p);
}
To Find:
- The output.
Language:
- Java.
Solution:
- The above loop iterates till the value of p is greater than 10.
- Inside the loop, value of p is first decremented and then it's value is printed.
So, the output goes like -
19181716151413121110
As no space is given, it will be somewhat difficult to read it.
Note: 10 is also printed as value of p is first decremented. When p is 11, it's value is decremented and p becomes 10. Now, p is displayed as while loop is an exit controlled loop. So, it checks the condition after completing one iteration.
Output:
19181716151413121110
•••♪
Similar questions