fork download
  1. // Blessie Grace Arcillas-2024104648, Chelcei Marie Cena-2024100800
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. // For Loop
  8. cout << "For Loop:" << endl;
  9. for (int i = 1; i <= 10; ++i) {
  10. cout << i << " ";
  11. }
  12. cout << endl << endl;
  13.  
  14. // While Loop
  15. cout << "While Loop:" << endl;
  16. int j = 1;
  17. while (j <= 10) {
  18. cout << j << " ";
  19. j++;
  20. }
  21. cout << endl << endl;
  22.  
  23. // Do-While Loop
  24. cout << "Do-While Loop:" << endl;
  25. int k = 1;
  26. do {
  27. cout << k << " ";
  28. k++;
  29. } while (k <= 10);
  30. cout << endl;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
For Loop:
1 2 3 4 5 6 7 8 9 10 

While Loop:
1 2 3 4 5 6 7 8 9 10 

Do-While Loop:
1 2 3 4 5 6 7 8 9 10