#include using namespace std; int main(){ int a 15; %3D int b 12; %3D int c 5; int pa &a; %3D int * pb &b; int * pc &c; %3D pb pc; %D pa pb; %3D II II cout << *pa « "," << *pb << "," << *pc << endl;

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

What is the correct output of the following example?

#include <iostream>
using namespace std;
int main(){
int a =
15;
int b
12;
int c
5;
int *
pa
&a;
%3D
int * pb = &b;
%D
int *
pc
&c;
pb
= pc;
pa
pb;
%D
<« *pb << "," << *pc << endl;
II II
cout << *pa <«
Transcribed Image Text:#include <iostream> using namespace std; int main(){ int a = 15; int b 12; int c 5; int * pa &a; %3D int * pb = &b; %D int * pc &c; pb = pc; pa pb; %D <« *pb << "," << *pc << endl; II II cout << *pa <«
Expert Solution
Step 1

Here we take three-pointer types variables pa, pb, and pc which are pointing at the memory locations a, b, and c respectively. Now the value at pa is 15 , at pb = 12 and at pc = 5.

 

Now, pb = pc so, value at pb = 5.

Now pa = pb so value at pa is also equals to 5. So, pa = pb = pc = 5.

Now, we are printing *pa which the value at the address pa i.e. 5, and similarly with pb and pc.

So, we get the output 5,5,5.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr