Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C: Assume an array has been declared as float arr [ 2 0 ] [ 8 ] ; What value of m can be

In C:
Assume an array has been declared as
float arr[20][8];
What value of m can be used so the following is true?
(float*)arr +m==&(arr[12][2])
(i.e., arr [12][2] is m floats ahead of arr in memory)
Note: you will lose 10% for each incorrect submission.
Answer:
Your Submission
Rating
Sub-Subject
Topic
C Programming Language
Passing Arrays To Functions
Step-by-step
Step 1 of 3
To find the value of m in,
1(float)arr+m==&(arr[12][2]),
we need to understand the memory layout of a 2D array.
In C, a 2D array is stored in a contiguous block of memory. The address of arr[0][0] is the same as the address of arr[0][1]+sizeof(float), Rows? v? neea to skip 1 rows (Irom inaex to |)1), and each row is 8 floats. So,12**8=96 floats.
Columns: We need to skip 2 columns (from index 0 to 1) in the 12th row, which is an additional 2 floats.
So,m=96+2=98.
Explanation:
Therefore, the correct answer is m=98.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

b. What groups were most represented? Why do you think this is so?

Answered: 1 week ago

Question

3. Describe phases of minority identity development.

Answered: 1 week ago

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago