What are the different types of loops in C++?

For Loop:-

for (int i = 0; i < 5; i++) { cout << i << "\n"; }

Example - To Print a Table of numbers from 1 to 10.

While Loop:-

int i = 0; while (i < 5) { cout << i << "\n"; i++; }

Example - To Accept user input until negative number is entered.

Do While Loop:-

int i = 0; do { cout << i << "\n"; i++; } while (i < 5);

Example - To execute the loop body at least once. I.e. start a menu based program to allow users to select a choice.