Diktat_ProgKecilBhsC

Xy return 0 d n x y x y file

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: char i, j; i=3; j=4; /* Algoritma */ if (i&&j) {…}; if (i&j) {…}; if (i||j) {…}; if (i|j) {…}; if (i^j) {…}; if (~i) {…}; /* /* /* /* /* /* true = true and true false = 00000000 */ true = true and true true = 00000111 */ true = 00000111 */ true = 11111000 */ /* File : exp.c */ /* pemakaian operator kondisional */ int main () { /* KAMUS */ int x = 1; int y = 2; /* ALGORITMA */ printf ("x = %d \n", x); printf ("y = %d \n", y); printf ("hasil ekspresi = (x<y)?x:y return 0; } = */ */ %d \n", (x < y) ? x : y); /* File : exp1.c */ /* pembagian integer, casting */ int main () {/* KAMUS */ int x = 1; int y = 2; float fx; float fy; /* ALGORITMA */ printf ("x/y (format integer) = %d \n", x/y); printf ("x/y (format float) = %f \n", x/y); /* supaya hasilnya tidak nol */ fx=x; fy=y; printf ("x/y (format integer) = %d \n", fx/fy); printf ("x/y (format float) = %f \n", fx/fy); /* casting */ printf ("float(x)/float(y) (format integer) = %d \n", (float)x/(float)y); printf ("float(x)/float(y) (format float) = %f \n", (float)x/(float)y); x = 10; y = 3; printf ("x/y (format integer) = %d \n", x/y); printf ("x/y (format float) = %f \n", x/y); return 0; } /* File : oper3.c */ /* Operator terner */ /* Ekspresi ditulis sebagai makro */ #define max(a,b) ((a>b) ? a: b) int main () { /* KAMUS */ int i = 0; /* perhatikan int i,j=0 bukan seperti ini */ int j = 0; char c = 8; char d = 10; char e = max (c, d); int k = max (i, j); /* ALGORITMA */ printf ("Nilai e = %d \n", e); printf ("Nilai k = %d \n", k); i = 2; j = 3; k = max (i++, j++); printf ("Nilai k = %d \n", k); return 0; } PEMBACAAN NILAI /* File : BACA.C */ /* contoh membaca integer */ /* kemudian menuliskan nilai yang dibaca */ int main () {/* Kamus */ int a; /* Program */ printf ("Contoh membaca dan menulis, ketik nilai integer: "); scanf ("%d", &a); printf ("Nilai yang dibaca : %d \n", a); return 0; } /* file : bacakar....
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