Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. In the following code snippet in C++, which of the variables will a compiler consider to have compatible types under structural and name equivalence?

1. In the following code snippet in C++, which of the variables will a compiler

consider to have compatible types under structural and name equivalence?

struct S {

int x[10];

};

struct T {

S x;

int y[10];

};

struct U {

int x[10];

S y;

};

S a;

int b[10];

T c;

U d;

2. Consider the following code snippet in C++. What will be the value of r?

Explain your answer in terms of IEEE754 representation.

int n = INT_MAX;

float r = *((float*) &n);

3. Consider the following code snippet in C++, compiled on a 64-bit x86 machine

(byte addressing). Assume the size of an integer in byte is 4.

int arr[4][4];

If the address of A[0][0] is 0x424fd0, what is the address of A[2][3]? Answer using

a hexadecimal representation.

4. Consider the following code snippet in C++, and determine the outputs.

int row = 4, col = 5;

int** d_matrix;

d_matrix = new int*[row];

for (int i = 0; i < row; i++) {

d_matrix[i] = new int[col];

}

for (int i = 0; i < row; i++) {

for (int j = 0; j < col; j++) {

d_matrix[i][j] = i * col + j;

}

}

cout << **d_matrix << endl;

cout << (*d_matrix)[2] << endl;

cout << *d_matrix[1] << endl;

cout << *(*(d_matrix+2)+3) << endl;

cout << *(d_matrix[3]+4) << endl;

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions