Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Coding Tugas 1
- #include <stdio.h>
- #define SIZE 4
- int main() {
- int a[][SIZE] = {{0,1,2,3}, {4,5,6}, {7,8,9,10} };
- int *p = &a[0][0];
- int *q = a[0];
- int *r = a[1];
- int *s = a[2];
- printf("%d ", *(p + SIZE + 1) );
- printf("%d ", p[SIZE + 1] );
- printf("%d ", p[2 * SIZE + 1] );
- printf("%d ", *(q + 2 * SIZE + 2) );
- printf("%d ", *r );
- printf("%d ", *(r - 2) );
- printf("%d\n", s[3] );
- return 0;
- }
- 2. Coding Tugas 2
- #include <stdio.h>
- int x = 2, y;
- void misteri(int a, int *b) {
- a = 2*x; *b = y; y = a;
- }
- int main() {
- x = 5; y = 7;
- misteri(y, &x);
- printf("%d %d\n", x, y);
- return 0;
- }
- 3. Coding Tugas 3
- #include <stdio.h>
- #define N 10
- void what(int *b, int n) {
- if (n) {
- printf("%d ", *b++);
- what(&b[0], n-1);
- }
- }
- int main() {
- int x[N]={10, 20, 30, 40, 50};
- what(x, 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment