fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. // Contoh perulangan while: mencetak angka 0 hingga 4
  5. int i = 0;
  6. while (i < 5) {
  7. std::cout << "Iterasi while ke-" << i << std::endl;
  8. i++; // Pastikan kondisi terpenuhi agar tidak terjadi infinite loop
  9. }
  10. return 0;
  11. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Iterasi while ke-0
Iterasi while ke-1
Iterasi while ke-2
Iterasi while ke-3
Iterasi while ke-4