Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include // Copy last three addresses of 'intarray' into 'ptr_array' which is an array of // pointers to an int. intarray and ptr_array are variable

#include

// Copy last three addresses of 'intarray' into 'ptr_array' which is an array of // pointers to an int. intarray and ptr_array are variable names. // you will do this by steps: Q1-Q3. int main() {

int intarray[5] = {1,2,3,4,5};

// pointer "pointer" below, points to an integer points, which points to // the first element in intarrary. int *pointer = (int *) &intarray; // points to the first element here.

// Q1. make "pointer" point to the 3rd element of intarray with value '3' (currently // it points to the first element with value '1')

// Q1: Insert code for Q1 below: printf("Q1 B: TODO : 'pointer' needs to point to the 3rd element of intarray ");

// below is an array of 3 pointers, pointing to integers. int *ptr_array[3];

// copy last three addresses of intarray into ptr_array int i; for( i = 0; i < 3; i++ ) { // Q2.insert code below, so that the elements in ptr_array points to // the last three elements in intarray // pointer should initially point to '3' // then you should increment the pointer // to the next element of intarray.

// Q2: Insert code for Q2 below:

printf("Q1 B: TODO : increment pointer ");

}

for (i = 0; i < 3; i++) { if (ptr_array[i] == &pointer[i]) { // Q3 - add printing out the content intarray ('3', '4', and '5' // in addition to pointer addresses

// Q3: replace the '666' token with a proper variable name (using ptr_array) printf("ptr_array[%d] == &pointer[%d] : %p : %d ", // i, i, ptr_array[i], 666 ); i, i, ptr_array[i], 666 ); printf("TODO: replace '666', above, with a variable "); } else { printf("ptr_array[%d] != &pointer[%d] : %p : %d ", i, i, ptr_array[i], 666 ); printf("TODO: replace '666', above, with a variable "); } }

return 0; }

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

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions