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
ورچوئل میموری میں میموری کے وسائل کن کے درمیان منظم اور مختص کیے جاتے ہیں؟
- Printers
- Processes
- Keyboards
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
وی پی این کا بنیادی مقصد کیا ہے؟
- To provide privacy and secure connections over networks
- To delete computer files
- To increase RAM
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
ای میل ایڈریس کا ڈومین والا حصہ عام طور پر کس چیز کی نشاندہی کرتا ہے؟
- The email password
- The organization or mail service domain
- The user's phone number
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
سرچ انجن کا بنیادی مقصد کیا ہے؟
- To create documents
- To search for information and websites
- To design presentations
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
نیٹ ورک کارڈ کے منفرد ہارڈویئر ایڈریس کو کیا کہتے ہیں؟
- IP Address
- MAC Address
- Email Address
- None of these