Arrays, Structs, Union Flashcards

1
Q

For an array initialised as int val[5]
What is the type and value of the reference:
val

A

Type: int *
Value: x

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

For an array initialised as int val[5]
What is the type and value of the reference:
val +1

A

Type: int *
Value: x + 4

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

For an array initialised as int val[5]
What is the type and value of the reference:
&val[2]

A

Type: int *
Value: x + 8

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

For an array initialised as int val[5]
What is the type and value of the reference:
*(val+1)

A

Type: int
Value: value of element in val[1]

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

For an array initialised as int val[5]
What is the type and value of the reference:
val + i

A

Type: int *
Value: x + 4*i

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

Array size of multidimensional arrays

A

R * C * k bytes
(where R is rows and C is columns)

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

What is the starting address of of A[i]

A

A + i * (C * K)

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

Difference between struct and Unions

A

In struct, each member is given a separate memory. While all members of union use the same memory location and so it can handle only one number at a time

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

Solving alignments problems

A

Remember what the lowest address must be divisible by what

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

How to reduce memory space of structs

A

Rearrange the elements by putting large data types first

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

How is the memory allocated for union

A

According to the largest element

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