Diktat_ProgKecilBhsC

Elemen 1 dibdk 10 dn maxab tab1 tab2 passing

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: Point arrp[10]; /* definisi, alokasi tabel statik */ /* Definisikan elemen tabel */ for (i = 0; i <= 9; i++) { arrp[i].x = i; arrp[i].y = i + 1; } /* tulis isi tabel */ for (i = 0; i <= 9; i++) { printf ("\n %d/%d", arrp[i].x, arrp[i].y); } return 0; } /* File : tarrstr.c */ /* Array of string: pendefinisian dan pengaksesan */ #define STRING char* int main () {/* KAMUS */ /* definisi array yang elemennya string, statik, dan seklaigus mengisi */ static STRING s[3] = {"the", "time", "is"}; /* definisi array yang elemennya string, dinamik */ STRING (*TabStr); /* deklarasi array of string */ int i; /* PROGRAM */ /* print isi s */ for (i = 0; i < 3; i++) { printf ("%s\n ", s[i]); } /* alokasi TabStr sebanyak 3 */ TabStr = (STRING *) malloc (3 * sizeof (STRING)); for (i = 0; i < 3; i++) { /* alokasi string yang merupakan elemen tabel */ *(TabStr + i) = (STRING) malloc (5 * sizeof (char)); printf ("\nInput Str[%d], maksimum 5 karakter : ", i); scanf ("%5s", *(TabStr + i)); /* mengisi nilai string */ printf ("\n Nilai Str[%d] : %5s\n ", i, *(TabStr + i)); } return 0; } /* File : arrstr.c */ /* Array of string: pendefinisian dan pengaksesan */ /* perhatikanlah permasalahannya */ int main () { /* KAMUS */ /* definisi array yang elemennya string, statik, dan sekaligus mengisi */ static char *s[3] = {"the", "time", "is"}; /* definisi array yang elemennya string, dinamik */ char *(*TabStr); int i; /* PROGRAM */ /* print isi s */ for (i = 0; i < 3; i++) { printf ("%s\n ", s[i]); } /* alokasi TabStr sebanyak 3 */ TabStr = (char **) malloc (3 * sizeof (char *)); for (i = 0; i < 3; i++) { *(TabStr + i) = (char *) malloc (5 * sizeof (char)); printf ("\nInput Str[%d], maksimum 5 karakter : ", i); scanf ("%5s", *(TabStr + i)); printf ("\n Nilai Str[%d] : %5s\n ", i, *(TabStr + i)); } return 0; } /* File : tabparam.c */ /* tabel sebagai parameter prosedur. Perhatikan cara passing parameter aktual */ #include <stdio.h> /* prototype */ int maxab (int a, int b); void tukar (int *a, int *b); void Offsettab (int *T, int Awal, int Akhi...
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