Monday, August 25, 2008

ECP1016 Tut 10

You guys can just ignore this..for my reference..haha.

1.
float *wPtr;

wPtr = NULL;

float w;
wPtr = &w;

printf("%d\n", *wPtr);

2.
vPtr

F8D

B

C

F8C

C

(unclear)

3.
a.1130
b.1134
c.1138
d.1130
e.0.002
f.0.002
g.1138
h.0.003
i.3x(0.003-0.002) = 0.003

4.

y = 5
x = 12
y = 5
xPtr = 15
y = 15

\*
int *aPtr = a;

int a[3] = {2, 5, 10};

aPtr = &a[0] ( 2 )
aPtr = &a[1] ( 5 )
aPtr = &a[2] ( 10 )
*\

6.
a.address of x[0] (10)
b.address of x[2] (30)
c.*x == 10
d.10 + 2 = 12
e.(*x+2) == 30

7.


a. unsigned int values[SIZE] = {2, 4, 6, 8, 10};

b. unsigned int = *vPtr;

c. vPtr = values;

*vPtr = values[0];

d. int i;
for (i=0;i (smaller) SIZE;i++) {
printf("%d\n", values + i);}

e. values[3]=8

f. vPtr = values[4]
(missed)...

5.
#include
#include

void square_cube (int n, int *square, int *cube)

int main(){

int n = 3;
int square, cube;

square_cube(n, square, cube);

printf("square = %d, cube = %d\n", *square, *cube);

return 0;
}

void square_cube (int n, int *square, int *cube)

square = pow(2);

No comments: