Question #24107

How much memory is set aside by the following commands? Show your work.

int nums[4];

double vals[5];

int nums[4];

double vals[5];

Expert's answer

As an int variable takes 2 bytes, then an array of 4 ints will take 8 bytes. So,

int nums[4];

sets 16 bytes of memory. Analogically, double variable usually takes 4 bytes, therefore

double vals[5];

sets 20 bytes.

int nums[4];

sets 16 bytes of memory. Analogically, double variable usually takes 4 bytes, therefore

double vals[5];

sets 20 bytes.

## Comments

## Leave a comment