-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatement_if.cpp
More file actions
40 lines (38 loc) · 896 Bytes
/
statement_if.cpp
File metadata and controls
40 lines (38 loc) · 896 Bytes
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
// if (kondisi) {
// ... <- ini disini adalah isi dari kode jika kondisi tersebut bernilai
// true
// }
//
// if statement
// if (kondisi) {
// ... <- blok kita buat
// } else {
// ... blok kode
// }
//
// if else else if
// if (kondisi) {
// ... <- blok kode ini
// } else if (kondisi) {
// .. <- blok kode ini yang akan di esekusi
// } else {
// .. <- jika diatas tidak ada satupun terpenuhi
// }
#include <iostream>
int main() {
int nilai;
std::cout << "masukkan nilai: ";
std::cin >> nilai;
if (nilai >= 90) {
std::cout << "grade: jago" << std::endl;
} else if (nilai >= 80) {
std::cout << "grade: sedikit jago" << std::endl;
} else if (nilai >= 70) {
std::cout << "grade: bolehlah" << std::endl;
} else if (nilai >= 60) {
std::cout << "grade: belajar lagi gan" << std::endl;
} else {
std::cout << "beban kali wak" << std::endl;
}
return 0;
}