Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trace the values of m, n, and *p through lines 3 8 of the code; that is, show how each of the variables changes through

  1. Trace the values of m, n, and *p through lines 3 8 of the code; that is, show how each of the variables changes through each line of the code. What is the output? 1 int m = 5, n = 7 ; 2 int *p ; 3 p = &n ; 4 *p = 2 * n + m ; 5 *p = 2 * n + m ; 6 p = &m ; 7 *p = 2 * m + n ; 8 *p = 2 * m + n ; 9 cout << "m = " << m << ", " ; 10 cout << "n = " << n << ", " ; 11 cout << "*p = " << *p << endl ;
  2. Consider the following code fragment: int x ; int *ptr = &x ; ptr++ ;If the variable x is stored at address 3173315904, what is the value of ptr after execution of the code fragment?
  3. Suppose I want to make an array of Graph objects using the Graph class from Project 1. Why will the following not work? Graph *GArray = new Graph[100] ;
  4. What output does the following code fragment produce? int arr[5] = {1,2,3,4,5} ; int *ptr = arr ; cout << *(ptr + 2) << 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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions