You are on page 1of 1

Course: DTPH C Programming

Trainee Number:
Trainee Name:

Code Tracing Exercise 7

Part I. Code Tracing (Score: ____ / 22 pts)

Program23.c (Pointer Basics) types.h


#include <stdio.h> #define U1 unsigned char
#include "types.h" #define U2 unsigned short
#define U4 unsigned long
U1 func(U1 *x, U1 y) {
printf("13)%d¥n", *x); #define S1 signed char
printf("14)%d¥n", y); #define S2 signed short
*x *= 2; #define S4 signed long
y = y + 3;
printf("15)%d¥n", *x);
printf("16)%d¥n", y);

return *x + y;
}

int main() { What is the output on the console when the


U1 a; main function is executed? (22 pts.)
U1 b = a = 1;
U1 *t; 1)
U1* u; 2)
U1 *v, *w; 3)
U1* x, y; 4)
U1 *z = &a; 5)
6)
printf("1)%d¥n", a); 7)
t = &a; 8)
a = 2; 9)
printf("2)%d¥n", t); 10)
printf("3)%d¥n", *t); 11)
*t = 3; 12)
printf("4)%d¥n", a); 13)
printf("5)%d¥n", &a); 14)
15)
printf("6)%d¥n", b); 16)
w = &b; 17)
v = w; 18)
w = &a; 19)
printf("7)%d¥n", *v); 20)
printf("8)%d¥n", *w); 21)
u = w = v; 22)
printf("9)%d¥n", *w);
printf("10)%d¥n", *u);

printf("11)%d¥n", sizeof(x));
printf("12)%d¥n", sizeof(y));
x = 5;
y = func(&a, b);
printf("17)%d¥n", y);
printf("18)%d¥n", a);
printf("19)%d¥n", b);
printf("20)%d¥n", x);
printf("21)%d¥n", *z);
printf("22)%d¥n", *x);
return 0;
}

You might also like