-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1-IOVar.cpp
More file actions
45 lines (35 loc) · 1.36 KB
/
1-IOVar.cpp
File metadata and controls
45 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream> // untuk bahasa C++
#include <string>
using namespace std;
int main(){
//cara ke-1 input statis hardcode
int angka = 10.5;
cout <<"Angka yang di input adalah : " << angka <<endl;
float angka2 = 10.5;
cout <<"Angka yang di input adalah : " << angka2 <<endl;
double angka3 = 10.566;
cout <<"Angka yang di input adalah : " << angka3 <<endl;
string sapa = "Hallo semua";
cout <<"Teks yang di input adalah :" <<sapa <<endl;
//cara ke-2 input dinamis
int nilai;
cout <<"Masukan Nilai :";
cin >> nilai;
cout<< "Nilai yang di input adalah : " << nilai <<endl;
//melihat size dari tipe data
cout << "Size of int : " << sizeof(int) << endl;
cout << "Size of short int : " << sizeof(short int) << endl;
cout << "Size of long int : " << sizeof(long int) << endl;
cout << "Size of float : " << sizeof(float) << endl;
cout << "Size of double : " << sizeof(double) << endl;
cout << "Size of char : " << sizeof(char) << endl;
cout << "Size of bool : " << sizeof(bool) << endl;
cout << "Size of string : " << sizeof(string) << endl;
cout << "Tipe Data Int" << endl;
// sizeof digunakan untuk melihat ukuran tipe data
cout << "Size " << sizeof(int) << " byte." << endl;
// INT_MIN dan INT_MAX digunakan jakauan terkecil/terbesar untuk INT
cout << "Range : " << INT_MIN;
cout << " s/d " << INT_MAX << endl;
return 0;
}