Day 10 Recap Questions
- What is a pointer?
- If
a
is an int variable, andp
is a variable whose type is pointer-to-int, how do you makep
point toa
? - If
p
is a pointer-to-int variable that points to anint
variablea
, how can you access the value ofa
or assign a value toa
without directly referring toa
? Show examples of printing the value ofa
and modifying the value ofa
, but without directly referring toa
. - When calling
scanf
, why do you need to put a&
symbol in front of a variable in which you wantscanf
to store an input value? - Trace the little program below and determine what the output will be.
int func(float ra[], float x, float *y) {
ra[0] += 10;
x *= 20;
*y += 30;
return 40;
}
int main() {
float a = 1;
float b = 2;
float c[] = {3, 4, 5, 6};
int d;
d = func(c, a, &b);
printf("%.2f, %.2f, %.2f, %d\n", a, b, c[0], d);
}