Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Operator Pada C Amaludin Arifia, M.Kom.

Presentasi serupa


Presentasi berjudul: "Operator Pada C Amaludin Arifia, M.Kom."— Transcript presentasi:

1 Operator Pada C Amaludin Arifia, M.Kom

2 Pembahasan Operator Aritmatika Operator Relasi Operator Logika

3 Operator Aritmatika Capture by How to C program 6th edition  Deitel

4 Precedence in Logical Operation
Operator Operation Order of evaluation (precedence) ( ) Parentheses Evaluated first If the parentheses are nested,the expression in the innermost pair is evaluated first. If there are several pairs of parentheses “on the same level” (not nested), they’re evaluated left to right. * Multiplication Evaluated second. If there are several, they’re evaluated left to right. / Division % Modulus + Addition Evaluated last. If there are several, they’re evaluated left to right. - Subtraction

5 Aturan precedence Operator didalam parenthese“()” akan di evaluasi Paling Pertama oleh compiler C  highest level of precedence Multiplication, division and remainder Operator ini akan dikerjakan setelah oprator “()” jika tidak ada maka akan dikerjakan pertama kali. jika terdapat banyak operasi, akan dikerjakan dari kiri ke kanan Addition and subtraction operations dikerjakan setelah Multiplication, division and remainder.

6 Example Y = A * X * X + B * X + C; Step 1. Y = 2 * 5 * 5 + 3 * 5 + 7;
2 * 5 is 10 Step 2. Y = 10 * * 5 + 7; 10 * 5 is 50 Step 3.Y = * 5 + 7; 3 * 5 is 15 Step 4. Y = ; is 65 Step 5. Y = ; is 72 Step 6. y = 72

7 Equality dan Operator Relasi

8 Equality dan Operator Relasi
Digunakan untuk Decission Statemen ( statemen keputusan ) ?

9 Example To determine if a student’s grade on an exam is greater than or equal to 60 and if it is to print the message “Congratulations! You passed.” in C  If(exam>=60) { printf(“Congratulations! You passed”); } else {(“Sorry you must study hard”); } Akan kita jumpai pada penggunaan IF, else, else if statemen. Hasil ungkapan akan bernila true atau false True jika memenuhi ungkapan false jika tidak memenuhi ungkapan.

10 Operator Logika && (logical AND), || (logical OR) dan ! (logical NOT also called logical negation)

11 Terima Kasih


Download ppt "Operator Pada C Amaludin Arifia, M.Kom."

Presentasi serupa


Iklan oleh Google