#include <iostream>
#include <math.h>
using namespace std;
int main() {
// Penamaan variabel
// a-z, A-Z, _, 0-9
// Di depan ga boleh angka -> kali2
// Ga boleh sama dgn keyword
// Tips: buat nama variabel se-deskriptif mungkin
// 4 primitive data types
// bil bulat
int angka; // -2^31 -- 2^31 - 1
long long panjang; // -2^63 -- 2^63 - 1
unsigned int positif; // 0 -- 2^32 - 1
angka = 2147483647;
cout << angka << endl;
// bil desimal
double desimal = 1.5;
cout << desimal << endl;
// character/simbol -> ASCII
char hurufA = 'A';
cout << hurufA << endl;
char hurufB = hurufA+1;
cout << hurufB << endl;
// boolean
bool benar = true;
bool salah = false;
// Operasi
int x = 1, y = 2, hasil;
hasil = x+y;
hasil = x-y;
hasil = x*y;
hasil = x/y;
hasil = x%y;
// Pembagian = hasil bagi
// Modulo = sisa bagi
// 11/3 = 3 + 2/3 -> 11/3 = 3, 11%3 = 2
hasil += x; // sama dengan hasil = hasil+x;
// sama juga utk operasi -, *, /, %
// increment & decrement
hasil++; // sama dengan hasil = hasil+1;
hasil--; // sama dengan hasil = hasil-1;
// Control Structure
// Linear
// Branching / Percabangan
// Looping / Perulangan
angka = 2;
switch(angka) {
case 1:
cout << "Masuk case 1" << endl;
break;
case 2:
cout << "Masuk case 2" << endl;
break;
default:
cout << "Masuk case default" << endl;
break;
}
if(!(angka > 0)) {
cout << "Masuk if" << endl;
}
else {
cout << "Masuk else" << endl;
}
// Ternary operation
if(hurufA == 'A') {
angka = 1;
}
else {
angka = 2;
}
angka = (hurufA == 'A') ? 1 : 2;
/*
1. https://tlx. toki.id/problems/troc-1/A
2. https://tlx. toki.id/problems/troc-2/A
3. https://tlx. toki.id/problems/troc-32/A
4. https://tlx. toki.id/problems/osn-2009/2A
https://ideone. com/4tlSgK
5. Buatlah sebuah program untuk mengubah nilai angka
menjadi huruf.
A: 86-100
B: 71-85
C: 56-70
D: 41-55
E: 0-40
Contoh input:
80
Contoh output:
B
https://ideone. com/stcfdR
*/
return 0;
}