---
title: "How many times will the following loop print hello? I = 1; while (I <= 10) cout << \"hello\"?"  
description: "How many times will the following loop print hello? I = 1; while (I <= 10) cout << \"hello\"?"  
author: "Mukul Goenka"  
published: 2021-11-11  
updated: 2023-06-06  
canonical: https://www.mindstick.com/interview/33817/how-many-times-will-the-following-loop-print-hello-i-1-while-i-10-cout-hello  
category: "c#"  
tags: ["programming language"]  
reading_time: 1 minute  

---

# How many times will the following loop print hello? I = 1; while (I <= 10) cout << "hello"?

```
#include <iostream>using namespace std;int main(){    int I = 1;    while (I <= 10)     cout << "hello";    return 0;}
```

It print "hello" infinite time. because loop has three part initialization, condition, and updation. In this program initialization and condition have word but updation in not work so value of "I" in not update. So all time value "I" is 1 , so condition is always true.

## Answers

### Answer by Aryan Kumar

The loop will print "hello" 10 times. The variable I is initialized to 1, and the loop will run while I is less than or equal to 10. The cout statement will print "hello" each time the loop runs.

### Answer by Mukul Goenka

```
#include <iostream>using namespace std;int main(){    int I = 1;    while (I <= 10)     cout << "hello";    return 0;}
```

It print "hello" infinite time. because loop has three part initialization, condition, and updation. In this program initialization and condition have word but updation in not work so value of "I" in not update. So all time value "I" is 1 , so condition is always true.


---

Original Source: https://www.mindstick.com/interview/33817/how-many-times-will-the-following-loop-print-hello-i-1-while-i-10-cout-hello

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
