Week 3 - Memory Basics, Pointers & Arrays Flashcards

1
Q

What is the output of the following program?

#include 
int main(){
  int a [10];
  for (int i = 0; i < 10; i++){
    a[i] = i;
  }
  int *pa = &a[3];
  printf("%ld\n", a[2] * (pa - a));
}
A

6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you declare an array of 10 pointers to char?

A

char *p[10]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a pointer?

A

a variable that contains the address of another variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is &?

A

address operator - gives the address of an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is *?

A

dereferencing operator - gives the value stored at an address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly