Program C++ Modul 2 – Kombinasi Tipe Data

Video Modul 2

Source Code:
/* Modul 2

Tipe Data, Konstanta dan Variable

Nama    : Rizqia Wulan Sari

NIM        : 49013098

Jurusan : TKJMD

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

#include
<iostream>
//file header iostream

#include
<limits>
//file library limits

using
namespace std; //menggunakan std namespace input dan output

const
int A = 5; //deklarasi konstanta

double hasil; //deklarasi variabel global

int main()

{

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

    cout << ”    TIPE DATA, KONSTANTA DAN VARIABLE\n”; //perintah output

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

    char nama[25] = “Rizqia Wulan Sari”; //perintah output

    char* nim = “49013098”; //perintah output

    char karakter; //deklarasi variabel tipe char

    float angka; //deklarasi variabel tipe float

    cout << ” Nama    : “ << nama << endl; //perintah output

    cout << ” NIM    : “ << nim << endl << endl; //perintah output

    cout << ” Masukkan sebuah karakter = “; //perintah output

    cin >> karakter; //perintah input

    cout << endl; //perintah output

    cout << ” Nilai ASCII dari karakter “ << karakter << ” = “ << (int) karakter << endl << endl; //perintah output char dikonversi menjadi integer

    cout << ” Masukkan angka = “; //perintah output

    cin >> angka; //perintah input

    hasil = angka*A; //inisialisasi hasil = angka dikali nilai konstanta

    cout << endl; //perintah output

    cout << ” Nilai konstanta A = “ << A << endl; //perintah output

    cout << ” Hasil dari angka dikali dengan nilai konstanta A = “ << hasil << endl << endl; //perintah output

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

    cout << ” Tipe Data Pada Library Limits \n”; //perintah output

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

    cout << ” Minimum char = “ << CHAR_MIN << endl; //perintah output

    cout << ” Maximum char = “ << CHAR_MAX << endl; //perintah output

    cout << ” Minimum int = “ << INT_MIN << endl; //perintah output

    cout << ” Maximum int = “ << INT_MAX << endl << endl; //perintah output

    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