Diktat_ProgKecilBhsC

C driver mesinkar1 menuliskan isi pita ke layar

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: r *c) { *c = *c - 1; } void geser (void *TT, void (*f) (void *)) { /* Kamus */ int i; /* Algoritma */ printf ("dalam geser \n"); for (i = 0; i < N; i++) { f (&TT[i]); printf (" %d ", TT[i]); } printf ("\n"); } void printtab (void *T, enum MyType Ty) { for (i = 0; i < N; i++) { switch (Ty) { case bulat: printf ("%d ", (int *) *(T + i)); break; case karakter: printf ("%c ", (char *) *(T + i)); break; } } } SCOPE & LIFETIME /* File : scope.c */ /* Scope and lifetime */ /* prototype */ void Pros1 (int, int, int *); int fungsi1 (void); /* KAMUS GLOBAL */ char CC; int main () {/* KAMUS LOKAL */ char CX; int i, j, k, h; float x, y; int ix; int idx; /* ALGORITMA */ CC = 'X'; CX = CC; i = 2; j = 3; k = 1; Pros1 (i, j, &h); printf ("Nilai k pada main = %d\n", k); printf ("Nilai h pada main = %d\n", h); for (idx = 0; idx < 6; idx++) { printf ("Hasil fungsi : %d\n", fungsi1 ()); } if (i < j) { int ii = 1; printf ("ii dideklarasi dalam blok if\n"); printf ("Nilai ii= %d\n", ii); } /* SALAH: tidak dikenal : printf ("Nilai ii= %d\n", ii); */ printf ("i = %d \n", i); return 0; } void Pros1 (int i, int j, int *h) {/* KAMUS LOKAL */ int k; /* ALGORITMA */ k = i + j; printf ("Nilai k pada pros1 = %d\n", k); *h = i + j; printf ("Nilai *h pada pros1 = %d\n", *h); } int fungsi1 () { /* KAMUS LOKAL */ int i=0; static int j = 0; /* ALGORITMA */ i= i+ 1; j = j + 1; printf ("Nilai j pada printf ("Nilai i pada return j; } fungsi1 = %d\n", j); fungsi1 = %d\n", i); /* File : blok.h */ /* Contoh deklarasi extern */ #ifndef blok_H #define blok_H typedef struct { int HH;...
View Full Document

Ask a homework question - tutors are online