#include <stdio.h> int munge(int A[], int size) ; main() { int X[15], result ; result = munge(X, 4) ; printf("X[0] = %d, X[1] = %d, X[2] = %d, X[3] = %d\n", X[0], X[1], X[2], X[3]) ; printf("result = %d\n", result) ; } int munge(int A[], int size) { int i ; for (i = 0 ; i < size ; i++){ A[i] = size - i ; } return(A[0]) ; }
Click here for the solution.
#include <stdio.h> main() { int a = 5, b = 7, *ptr1, *ptr2 ; ptr1 = &a ; ptr2 = &b ; *ptr2 = *ptr1 + b ; ptr1 = ptr2 ; *ptr1 = a + b ; printf("a = %d, b = %d, *ptr1 = %d, *ptr2 = %d\n", a, b , *ptr1, *ptr2) ; }
Click here for the solution.
#include <stdio.h> void foo(int *, int *) ; main() { int a = 1, b = 3; foo(&a, &b) ; printf("a = %d, b = %d\n", a, b) ; foo(&a, &a) ; printf("a = %d, b = %d\n", a, b) ; } void foo(int *p1, int *p2) { *p1 = *p2 + 5 ; *p2 = *p1 - 1 ; }
Click here for the solution.