Penggunaan Pengulangan For Bersarang pada Bahasa C++

Latihan Modul 6.4

Nama : Haidi

No.Reg : 49031064

  1. Ubah format tampilan pada modul di atas dengan menggunakan pengulangan for bersarang, dengan format tampilan sbb :

modul6.4

  1. // Modul6.4.cpp : Defines the entry point for the console application.
  2. //
  3. #include “stdafx.h”
  4. #include <iostream>
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8.        for (int j=0; j<=10; j++){
  9.               for (int k=0; k<=j; k++){
  10.                      cout << k+j <<‘ ‘;
  11.               }
  12.               cout <<“\n”;
  13.        }
  14.        system(“pause”);
  15.               return 0;
  16. }

 

Leave a comment