Pointers are addresses and have a numerical value. You can print out the value of a pointer as cout << (unsigned)(p). Write a program to compare p, p + 1, q, and q + 1, where p is an int* and q is a double*. Explain the results.

Answers

Answer 1

Answer:

#include <iostream>

using namespace std;

int main() {

  int i = 2;

  double j = 3;

 

  int *p = &i;

  double *q = &j;

 

  cout << "p = " << p << ", p+1 = " << p+1 << endl;

  cout << "q = " << q << ", q+1 = " << q+1 << endl;

  return 0;

}

Explanation:

In C++, pointers are variables or data types that hold the location of another variable in memory. It is denoted by asterisks in between the data type and pointer name during declaration.

The C++ source code above defines two pointers, "p" which is an integer pointer and "q", a double. The reference of the variables i and j are assigned to p and q respectively and the out of the pointers are the location of the i and j values in memory.


Related Questions

A series of gentle often open-ended inquiries that allow the client to progressively examine the assumptions and interpretations here she is made about the victimization experience is called:_____.

Answers

Answer:

Trauma Narrative

Explanation:

Given that Trauma narrative is a form of narrative or carefully designed strategy often used by psychologists to assists the survivors of trauma to understand the meaning or realization of their experiences. It is at the same time serves as a form of openness to recollections or memories considered to be painful.

Hence, A series of gentle often open-ended inquiries that allow the client to progressively examine the assumptions and interpretations he or she is made about the victimization experience is called TRAUMA NARRATIVE

Other Questions
I need help with homework! The question given was, "Choose one way that people can participate in the political process to discuss and record an example of what that might look like in real life." Please help me! HELP!!!!!!!!!!! Draw a simple transverse wave and label the wavelength. What word matches best What is the solution set for -4x - 10 2?x -3x -3x 2x 2 According to the graph, when does the bacteria population reach its peak?A)FebruaryB)MarchC)NovemberD)September Tempo Company's fixed budget (based on sales of 16,000 units) for the first quarter reveals the following FixedBudgetSales (16,000 units X $211 per unit) 2184,000 Cost of goods sold Direct materials 322,000Direct labor 602,000Production supplies 392,000Plant manager salary 122,000 14,38,000Gross profit 13,76,000Selling expenses Sales commissions 112,000Packaging 210,000Advertising 100,000 422,000 Administrative expenses Administrative salaries 172,000Depreciation-office equip. 142,000Insurance 112,000Office rent 122,000 548,000Income from operations 406,000 (1) Compute the total variable cost per unit. (2) Compute the total fixed costs. (3) Compute the income from operations for sales volume of 14,000 units. (4) Compute the income from operations for sales volume of 18,000 units. Question 6 (10 points)The Washington Monument in our nation's capital is 555 ft high. Neglecting the effects of air resistance, what would be thespeed of the penny as it "hit" the ground?ObOcOd48.3 m/s-68.4 m/s84.7 m/s-57.6 m/s Which of the following statements is true about cellular respiration?A.Aerobic respiration produces substantially more ATP than anaerobic respiration.B.Anaerobic respiration produces substantially more ATP than aerobic respiration.C.Aerobic respiration occurs before glycolysis.D.Anaerobic respiration occurs before glycolysis Describe how England established territorial claims in North America. Include these terms in your answer: John Cabot, London Company, Jamestown. The best description of native North Americans before the arrival of the Europeans is that a. They lived a "hand-to-mouth" existence and just barely made a living. b. They were members of highly complex and sophisticated societies. c. They lived in a world that was biologically and culturally diverse. d. Regardless of where they lived, they all lived basically the same way. 4) How did the Seminole Native Americans unknowingly lead to the USacquiring Florida? The ratio of boys to girls in Coach Sheppard's class is 3 to 5. There are 20 girls in theclass.What is the total number of students in Coach Sheppard's class? Som eone g ive me motiva tion for school i fa iled every class then I d k anymore so MAny a-sigmentsanyon e else- Does anyone know how to do this Ive been trying for hours and I cant find anything to help me? Write an equation for the sentence. A pizza with 15 slices is shared equally among n students. Each student gets 3 slices. Plzzzzz helppppp meeee.!!!!!!!!! pls help i'll give branliest ________ is defined as average kinetic energy.A. temperatureB. volumeC. heatD. pressure Part BWho is the intended audience for Lincoln's address? Based on the content, how does Lincoln view these different groups ANSWER ASAP FOR 35 POINTS!! A pool has a diameter of 12 feet and a height of 2 feet. If each cubic foot holds 7.48 gallons of water, about how many gallons of water can the pool hold? Use 3.14 for pi. A) 6764 gallonsB) 2255 gallonsC) 1691 gallonsD) 564 gallons