Program C++ Modul 3 – Kombinasi Operator Bagian I

Video Modul 3

Source Code:
/* Modul 3

Operator Assignment, Unary, Increment dan Decrement

Nama    : Rizqia Wulan Sari

NIM        : 49013098

Jurusan    : TKJMD

=====================================================*/

#include
<iostream>
//file header iostream

using
namespace std; //std namespace untuk perintah input dan output

int main() //fungsi utama program C++

{

    int c, d; //variabel bertipe integer

    float a, b; //variabel bertipe float

    double e, f; //variabel bertipe double

    cout << “===============================\n”; //perintah output

    cout << ”        OPERATOR” << endl; //perintah output

    cout << “===============================\n” << endl; //perintah output

    cout << ” Nama    : Rizqia Wulan Sari\n”; //perintah output

    cout << ” NIM    : 49013098\n\n”; //perintah output

    cout << ” Masukkan nilai a (desimal) = “; //perintah output

    cin >> a; //perintah input nilai a

    b = a; //inisialisasi nilai b = nilai a

    cout << ” Masukkan nilai c = “; //perintah output

    cin >> c; //perintah input nilai c

    d = -c; //inisialisasi nilai d = nilai -c

    cout << ” Masukkan nilai e (desimal) = “; //perintah output

    cin >> e; //perintah input nilai e

    cout << ” Masukkan nilai f (desimal) = “; //perintah output

    cin >> f; //perintah input nilai f

    cout << endl; //perintah output baris baru

    cout << ” Operator Assignment\n”; //perintah output

    cout << “===============================\n”; //perintah output

    cout << ” Nilai a = “ << a << endl; //perintah output nilai a

    cout << ” Nilai b = a adalah “ << b << endl << endl; //perintah output nilai b

    cout << ” Operator Unary\n”; //perintah output

    cout << “===============================\n”; //perintah output

    cout << ” Nilai c = “ << c << endl; //perintah output nilai c

    cout << ” Nilai d = -c adalah “ << d << endl << endl; //perintah output nilai d

    cout << ” Operator Increment\n”; //perintah output

    cout << “===============================\n”; //perintah output

    cout << ” Nilai e = “ << e << endl; //perintah output nilai e awal

    cout << ” Nilai ++e = “ << ++e << endl; //perintah output nilai ++e

    cout << ” Nilai e = “ << e << endl << endl; //perintah output e akhir

    cout << ” Operator Decrement\n”; //perintah output

    cout << “===============================\n”; //perintah output

    cout << ” Nilai f = “ << f << endl; //perintah output nilai f awal

    cout << ” Nilai f– = “ << f– << endl; //perintah output nilai f–

    cout << ” Nilai f = “ << f << endl << endl; //perintah output nilai f akhir

    system(“pause”); //untuk memberikan jeda

    return 0; //akhir fungsi main()

}

Hasil program:

 

Video tutorialnya:

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