Diktat_ProgKecilBhsC

Hh 3600 jmm 60 jss jam detiktojam int d konversi

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: Tab[i]); } printf ("\n"); geser (MyTab, succ); printf ("dalam main \n"); for (i = 0; i < N; i++) { printf (" %d ", MyTab[i]); } printf ("\n"); return 0; } /* BODY FUNGSI */ void succ (int *i) { *i = *i + 1; } void pred (int *i) { *i = *i - 1; } void geser (int *TT, void (*f) (int *)) { int i; printf ("dalam geser \n"); for (i = 0; i < N; i++) { f (&TT[i]); printf (" %d ", TT[i]); } printf ("\n"); } /* File : pointf5.c */ /* Pointer ke function */ /* Prosedur dengan parameter input/output sebagai parameter */ /* Melakukan offset terhadap tabel tergantung fungsi f */ /* KAMUS GLOBAL */ int N; /* ukuran efektif */ enum MyType { bulat, karakter }; /* prototype */ /* fungsi yang diberikan sebagai parameter aktual */ void succI (int *i); /* suksesor */ void predI (int *i); /* predesesor */ void succC (char *i); /* suksesor */ void predC (char *i); /* predesesor */ void printtab (void *T); /* print tabel yang belum ketahuan typenya */ /* prosedur dengan parameter sebuah fungsi yang argumennya belum jelas */ void geser (int *TT, void (*f) (void *)); /* PROGRAM UTAMA */ int main () { /* KAMUS LOKAL */ void *MyTabInt; void *MyTabC; int i; /* Algoritma */ N = 10; MyTabInt = (int *) malloc (N * sizeof (int)); MyTabC = (char *) malloc (N * sizeof (char)); *MyTabInt= 1 ; for (i = 0; i < N; i++) { *(MyTabInt + i) = i; *(MyTabC + i) = 'Z'; } printf ("Isi tabel dalam main sebelum pemanggilan \n"); printf ("table integer \n "); printtab ((int *) MyTabInt); printf ("table character \n "); printtab ((char *) MyTabC); printf ("\n"); geser ((int *) MyTabInt, (int *) succI); geser ((char *) MyTabC, (char *) succC); printf ("dalam main \n"); printf ("table integer \n "); printtab ((int *) MyTabInt); printf ("table character \n "); printtab ((char *) MyTabC); printf ("\n"); return 0; } /* BODY FUNGSI */ void succI (int *i) { } *i = *i + 1; void predI (int *i) { *i = *i - 1; } void succC (char *c) { *c = *c + 1; } void predC (cha...
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