Penggunaan Perulangan For pada Bahasa C++

Latihan Modul 6.3

Nama : Haidi

No.Reg : 49031064

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

modul6.3

  1. // Modul6.3.cpp : Defines the entry point for the console application.
  2. //Nama : Haidi
  3. //NIM  :49013064
  4. #include “stdafx.h”
  5. #include <iostream>
  6. using namespace std;
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9.        char nama[50],NRP[10];
  10.        int c,d;
  11.        cout <<“Pengulangan Menaik & Menurun” <<endl;
  12.        cout <<“Nama : “;
  13.        cin.getline(nama,50);
  14.        cout <<“NRP : “;
  15.        cin.getline(NRP,10);
  16.        for (c=0; c<6; c++){
  17.               cout << c <<endl;
  18.        }
  19.        for (d=5; d>0; d–){
  20.               cout <<d-1 << endl;
  21.        }
  22.        system(“pause”);
  23.        return(0);
  24. }

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s