Determine the output of the program: int x = 0; while (x < 5) { x += 2; } cout << x;
- 4
- 5
- 6
- 7
Explanation
- Initial value: x = 0
- Loop runs while x < 5
Iterations:
- 1st: x = 0 + 2 = 2
- 2nd: x = 2 + 2 = 4
- 3rd: x = 4 + 2 = 6
- Now x = 6, condition x < 5 becomes false, loop stops.
- Final value printed is 6.
Related MCQs
پہلی خاتون کمپیوٹر پروگرامر کون تھیں؟
- Ada Lovelace
- Grace Hopper
- Katherine Johnson
- Margaret Hamilton
اس سوال کو وضاحت کے ساتھ پڑھیں
ہینڈ ہیلڈ کمپیوٹر سے کیا مراد ہے؟
- Can be held and operated in the hand
- Requires a large room
- Is used only for scientific research
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
پرل پروگرامنگ زبان کس نے تیار کی؟
- Dennis Ritchie
- James Gosling
- Larry Wall
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
وہ زبان جسے کمپیوٹر سمجھ اور چلا سکتا ہے۔ وہ کیا کہلاتی ہے؟
- Machine language
- Application software
- System program
- All of the above
اس سوال کو وضاحت کے ساتھ پڑھیں
کسی ایک فرد کے استعمال کے لیے بنایا گیا چھوٹا کمپیوٹر کیا کہلاتا ہے؟
- Mainframe computer
- Supercomputer
- Personal computer
- None of these