int k=1, i=2; while(++i<6) k*=i; systems.out.printin(k);
Answers
Answered by
2
Required Answer:-
Correct C∅de:
int k=1, i=2;
while(++i<6)
k*=i;
System.out.println(k);
To Find:
- The output of the above c∅de (Java).
Output:
>> 60
Explanation:
- The above loop iterates if ++i < 6 is true.
- i becomes 3 (post-increment)
- k is multiplied with i.
- k = 1 × 3 = 3
- Again, value of i is incremented by 1.
- i becomes 4.
- k = 3 × 4 = 12
- Again, value of i is incremented.
- i becomes 5.
- k = 12 × 5 = 60
- i becomes 6 (incremented)
- 6 < 6 is false. Loop is terminated.
- Value of k is displayed.
- Output: 60.
Similar questions
Hindi,
1 month ago
Math,
1 month ago
Social Sciences,
1 month ago
Social Sciences,
3 months ago
Business Studies,
10 months ago
Business Studies,
10 months ago