C++ Programming Code Examples C++ > For Loops and While Loops Code Examples Infinite While loop in C++ programming language Infinite While loop in C++ programming language A while loop that never stops is said to be the infinite while loop, when we give the condition in such a way so that it never returns false, then the loops becomes infinite and repeats itself indefinitely. An example of infinite while loop: This loop would never end as I'm decrementing the value of i which is 1 so the condition i<=6 would never return false. #include <iostream> using namespace std; int main(){ int i=1; while(i<=6) { cout<<"Value of variable i is: "<<i<<endl; i--; } } Example: Displaying the elements of array using while loop #include <iostream> using namespace std; int main(){ int arr[]={23,88,13,99, -26}; /* The array index starts with 0, the first element of array has 0 index and represented as arr[0] */ int i=0; while(i<5){ cout<<arr[i]<<endl; i++; } }