Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . The following declarations are an attempt to access the array data using subscripts that start at one. Will it work? Why or why

1. The following declarations are an attempt to access the array data using subscripts that start at one. Will it work? Why or why not? ```c++ int actual_data[20]; int* data = actual_data - 1; ``` 2. What are the differences (if any) between the variables `array1` and `array2` in this function? ```c++ void function(int array1[10] ) { int array2[10]; ... } ``` 3. Given the declarations and data shown below, evaluate each of the expressions and state its value. Evaluate each expression with the original data shown (that is, the results of one expression do not affect the following one). Assume that the ints array begins at location 1000 and that integers and pointers both occupy *four* bytes of memory. Note: Some expressions are undefined. ```c++ int ints[20] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 120, 130, 140, 150, 160, 170, 180, 190, 200 }; int *ip = ints + 3; ``` | Expression | Value | Expression | Value |

| ------------- | -------------| ----------- | ------------- | | `ints` |-------------| `ip` |-------------- | | `ints[4]` |-------------| `ip[4]` |-------------- | | `ints + 4` |-------------| `ip + 4` | -------------- | | `*ints + 4` |-------------| `*ip + 4` | -------------- | | `*(ints + 4)` |-------------| `*(ip + 4)` | -------------- | | `ints[-2]` |-------------| `ip[-2]` | -------------- | | `&ints` |------------ | `&ip` |-------------- | | `&ints[4]` |-------------| `&ip[4]` | -------------- | | `&ints + 4` |------------- | `&ip + 4` | -------------- |

20. Recall that C++ is row-major language. Given the declaration: .....c++ int array[4][2]; ... Give the value of each of the following expressions. Assume that the array begins at location 100 and that integers occupy two bytes of memory

| Expression | Value | | -------------- | ------------- | | `array` |------------- | | `array + 2` |------------- | | `array[3]` |------------- | | `array[2] - 1` |------------- | | `&array[1][2]` |------------- | | `&array[2][0]` |------------- |

Anyone help me reply to these problems? I want to check my answer with this answer... Thanks

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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

A full job description of an accountant in details?

Answered: 1 week ago

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago