Diktat_ProgKecilBhsC

# H kamus boolean bool1 bool2 tf int ij hsl float

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: mp; ~8); /* 1 AND 0111 */ printf ("y << 2 = %d \n", y << 2); /* 10 ==> 1000 = 8 */ printf ("y >> 3 = %d \n", y >>3);; /* 10 ==> 0000 = 0 */ return 0; } /* File : oprator.c */ /* Contoh pengoperasian variabel bertype dasar */ int main () #include "boolean.h" {/* Kamus */ boolean Bool1, Bool2, TF ; int i,j, hsl ; float x,y,res; /* algoritma */ printf ("Utk program ini, baca teksnya dan tambahkan output"); Bool1 = true; Bool2 = false; TF = Bool1 && Bool2 ; /* Boolean AND */ TF = Bool1 || Bool2 ; /* Boolean OR */ TF = ! Bool1 ; /* NOT */ TF = Bool1 ^Bool2; /* XOR */ /* operasi numerik */ i = 5; j = 2 ; hsl = i+j; hsl = i - j; hsl = i / j; hsl = i * j; hsl = i /j ; /* pembagian bulat */ hsl = i%j ; /* sisa. modulo */ /* operasi numerik */ x = 5.0 ; y = 2.0 ; res = x + y; res = x - y; res = x / y; res = x * y; /* operasi relasional numerik */ TF = (i==j); TF = (i!=j); TF = (i < j); TF = (i > j); TF = (i <= j); TF = (i >= j); /* operasi relasional numerik */ TF = (x != y); TF = (x < y); TF = (x > y); TF = (x <= y); TF = (x >= y); return 0; } /* File : oper2.c */ /* pemakaian beberapa operator terhadap RELATIONAL DAN bit */ int main () {/* KAMUS */ char i, j; /* ALGORITMA */ i = 3; /* 00000011 dalam biner */ j = 4; /* 00000100 dalam biner */ printf ("i = %d \n", i); printf ("j = %d \n", j); printf (" true=> true printf (" printf (" => true */ printf (" printf (" printf (" return 0; } i && j */ i&j i|| j = %d \n", i && j);/* 1:op lojik : true and i| j i^j ~i = %d \n", i | j); /* 7: 00000111 biner */ = %d \n", i ^ j); /* 7: 00000111 biner */ = %d \n", ~i); /* -4: 11111100 biner */ = %d \n", i & j); /* 0: 00000000 dalam biner */ = %d \n", i || j); /* 1 : OR LOJIK, True or true Perhatikanlah operator boolean dibandingkan operator bit jika dipakai dalam ekspresi kondisional: /* KAMUS */...
View Full Document

## This document was uploaded on 03/15/2014 for the course IF 2030 at Institut Teknologi Bandung.

Ask a homework question - tutors are online