

Pemrograman C- Operator
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Medium
Mustaqim undefined
Used 7+ times
FREE Resource
19 Slides • 18 Questions
1
Memahami Operator dasar pada Program C
Apa itu Operator?
Operator adalah sebuah Simbol yang digunakan untuk melakukan operasi tertentu.
2
Jenis-jenis Operator
Ada enam jenis kelompok operator dalam pemrograman C:
Operator Artimatika;
Operator Penugasan;
Operator Pembanding;
Operator Logika;
Operator Bitwise;
3
1. Operator Aritmatika
Simbol | Nama Operator | Contoh |
|---|---|---|
+ | Penjumlahan | a + b |
- | Pengurangan | a - b |
* | Perkalian | a * b |
/ | Pembagian | a / b |
% | Sisa Bagi | a % b |
++ | Increment (menaikkan 1 pada nilai varibel) | ++a sama dengan a = a+1 |
-- | Decrement (mengurangi 1 pada nilai varibel) | --a sama dengan a = a - 1 |
4
Contoh 1
#include <stdio.h>
int main() {
int x = 5;
int y = 2;
printf("%d\n", x % y);
y= 3;
printf("%d", x % y);
return 0;
}
1
2
output :
5
Contoh 2
#include <stdio.h>
int main() {
int x = 5;
printf("%d", ++x);
return 0;
}
6
output :
6
Contoh 3
#include <stdio.h>
int main() {
int x = 5;
printf("%d", --x);
return 0;
}
4
output :
7
Multiple Choice
int x = 10;
...x ;
Operator yang tepat pada ...... untuk menaikkan 1 nilai variabel x adalah
++
+
+=
8
Multiple Choice
int x = 5;
++x ;
Setelah perintah diatas, nilai variabel x adalah
4
6
9
Multiple Choice
int x = 5;
--x ;
Setelah perintah diatas, nilai variabel x adalah
4
6
10
Multiple Choice
int x = 6;
int y = 2;
printf("%d\n", x % y);
Setelah perintah diatas, nilai variabel x adalah
0
3
4
11
Multiple Choice
int x = 7; int y = 4; printf("%d\n", x % y);
Setelah perintah diatas, output yang tampil dilayar adalah
1
2
3
12
2. Operator Asignment/Penugasan
Simbol | Contoh | Bentuk lain |
|---|---|---|
= | a = 5 | a = 5 |
+= | a += 5 | a = a +5 |
-= | a -= 5 | a = a - 5 |
*= | a *= 5 | a = a * 5 |
/= | a /= 5 | a = a / 5 |
%= | a %=5 | a = a % 5 |
Operator penugasan digunakan untuk mengisi variabel dengan suatu nilai
13
Contoh
#include <stdio.h>
int main() {
int x = 5;
x += 3;
printf("%d", x);
return 0;
}
8
output :
14
Contoh
#include <stdio.h>
int main() {
int x = 5;
x -= 3;
printf("%d", x);
return 0;
}
2
output :
15
Multiple Choice
int x = 10;
x .... 5;
Perhatikan potongan program diatas.
operator penugasan pada ...... untuk menambah nilai 5 pada variabel x adalah.
+=
+
++
16
Multiple Choice
int x = 10;
x += 5;
Perhatikan potongan program diatas.
Setelah perintah diatas, nilai variabel x menjadi .....
5
10
15
17
Multiple Choice
x += 5;
perintah berikut yang bermakna sama dengan perintah diatas adalah
x = 5
x = x + 5
++x
18
Multiple Choice
x = x - 3;
perintah berikut yang bermakna sama dengan perintah diatas adalah
x -= 3
x =- 3
--x
19
3. Operator Relasi/Pembanding
Simbol | Arti /Makna Operator | Contoh |
|---|---|---|
== | Sama dengan | 5 == 3 adalah False |
!= | Tidak sama dengan | 5 != 3 adalah True |
> | Lebih dari | 5 > 3 adalah True |
< | Kurang dari | 5 < 3 adalah False |
>= | Lebih dari atau Sama | 5 >= 3 adalah True |
<= | Kurang dari atau Sama | 5 <= 3 adalah False |
Operator untuk memeriksa hubungan atau membandingkan dua nilai
menghasilkan nilai True (1) atau False (0)
20
Contoh
#include <stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x == y);
// hasil 0 (false) karena 5 adalah tidak sama 3
return 0;
}
0
output :
21
Contoh
#include <stdio.h>
int main() {
int x = 5;
int y = 3;
printf("%d", x != y);
// hasil 1 (true) karena 5 adalah tidak sama 3
return 0;
}
1
output :
22
Contoh
#include <stdio.h>
int main() {
int x = 9;
int y = 5;
printf("%d", x >= y);
// hasil 1 (true) karena 9 adalah lebih dari 5
return 0;
}
1
output :
23
Contoh
#include <stdio.h>
int main() {
int x = 9;
int y = 5;
printf("%d", x <= y);
// hasil 0 (false) karena 9 adalah lebih dari 5
return 0;
}
0
output :
24
Multiple Choice
int x = 5;
int y = 3;
printf("%d", x == y);
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)
1 (true)
25
Multiple Choice
int x = 5;
int y = 3;
printf("%d", x != y);
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)
1 (true)
26
Multiple Choice
int x = 5;
int y = 5;
printf("%d", x >= y);
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)
1 (true)
27
Multiple Choice
int x = 5;
int y = 5;
printf("%d", x <= y);
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)
1 (true)
28
Multiple Choice
int x = 5;
int y = 5;
printf("%d", x < y);
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)
1 (true)
29
Multiple Choice
int x = 5;
int y = 3;
Perhatikan potongan program diatas.
Manakah dari perintah berikut yang menghasilkan 0 (false)
printf("%d", x < y); printf("%d", x > y); printf("%d", x >= y); 30
Multiple Choice
int x = 5;
int y = 3;
Perhatikan potongan program diatas.
Manakah dari perintah berikut yang menghasilkan 1 (True)
printf("%d", x == y); printf("%d", x <= y); printf("%d", x >= y); 31
4. Operator Logika
Simbol | Arti /Makna Operator | Contoh |
|---|---|---|
&& | logika DAN : TRUE jika semua pernyataan TRUE | (x < 5) && (x < 10) |
|| | logika ATAU: TRUE jika salah satu pernyataan TRUE | (x < 5) || (x < 4) |
! | Negasi (Kebalikan) | ! (x < 5 && x < 10) |
Operator logika digunakan untuk menentukan nilai logika suatu pernyataan atau variabel atau nilai
32
Logika AND (dan)
a | b | a && b |
|---|---|---|
TRUE | TRUE | TRUE |
TRUE | FALSE | FALSE |
FALSE | TRUE | FALSE |
FALSE | FALSE | FALSE |
Tabel Kebenaran operasi logika AND
a && b bernilai TRUE jika a TRUE, b TRUE
33
Logika OR (atau)
a | b | a || b |
|---|---|---|
TRUE | TRUE | TRUE |
TRUE | FALSE | TRUE |
FALSE | TRUE | TRUE |
FALSE | FALSE | FALSE |
Tabel Kebenaran operasi logika OR
a || b bernilai TRUE, jika salah satu bernilai TRUE
34
Contoh
#include <stdio.h>
int main() {
int x = 5; int y = 3;
int a,b;
a = (x>3); //true
b = (y <10); //true
printf("%d", a && b);
// hasil 1 (true) karena a true DAN b true
return 0;
}
1
output :
35
Multiple Choice
int x = 5;
int y = 3;
printf("%d", (x>3) && (y<10));
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)1 (true)36
Multiple Choice
int x = 5;
int y = 3;
printf("%d", (x<y) && (y<x));
Perhatikan potongan program diatas.
Hasil perintah diatas adalah .....
0 (false)1 (true)37
Terima Kasih
Semoga bermanfaat....
Memahami Operator dasar pada Program C
Apa itu Operator?
Operator adalah sebuah Simbol yang digunakan untuk melakukan operasi tertentu.
Show answer
Auto Play
Slide 1 / 37
SLIDE
Similar Resources on Wayground
33 questions
สาธิตการสอน
Presentation
•
12th Grade
31 questions
Pemrograman Bahasa C
Presentation
•
11th Grade
31 questions
Rational Graph Characteristics
Presentation
•
10th - 11th Grade
34 questions
Stoichiometry Review
Presentation
•
10th - 12th Grade
30 questions
GDP
Presentation
•
12th Grade
32 questions
LMC Recap
Presentation
•
12th Grade
32 questions
Descubriendo etiquetas HTML
Presentation
•
12th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade