Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EXERCISES FOR C++ 1) Declare a pointer to an integer. Declare an integer say month. Use the pointer to change month to 1 then output

EXERCISES FOR C++

1) Declare a pointer to an integer. Declare an integer say month. Use the pointer to change month to 1 then output the result. You must use the pointer for all of your code. Also properly initialize the pointer.

2) Use the Point class to declare 2 Point objects (could be of any x,y) and 2 pointers to those objects. Declare a double variable to represent the distance between the two points. Compute the distance using the pointers. Hint: distance = sqrt ( (x2-x1)2 + (y2-y1)2 ). Must use the pointers in your calculation.

3) Assuming the following fragment of code:

int day = 21;

int month = 9;

int * p1 = NULL;

int * p2 = NULL;

int * p3 = NULL;

p1 = &day;

p2 = &month;

p3 = p1;

p1 = p2;

p3 = p2;

p1 = NULL;

Draw diagram of day, month, p1, p2, and p3 similar to the diagram shown in section "Pointers to double" in sub-module "Pointer to primitive data types".

The purpose is to show the changes of the pointers after each statement is executed.

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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

Define Decision making

Answered: 1 week ago

Question

2 The main characteristics of the market system.

Answered: 1 week ago