Given the following program fill in the blanks resulting from the cout statements: int c1 = 3; int c2-5; int c3-7; int* p1 ; int* p2; int* p3 p1 = &c2; p2 = &c3; p3 = &c1; *p1 = *p2: p2 = p3 (*p2)+; *p3 = *p1 - *p2; p2 - &c2;

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
Question

Be quick pls

Given the following program, fill in the blanks resulting from the `cout` statements:

```cpp
int c1 = 3; 
int c2 = 5; 
int c3 = 7;
int* p1; 
int* p2; 
int* p3;

p1 = &c2;
p2 = &c3;
p3 = &c1;
*p1 = *p2;
p2 = p3;
(*p2)++;
*p3 = *p1 + *p2;
p2 = &c2;
c2 = c3 + *p1;
```

1. What is the value of `c1`? 
   
2. What is the value of `c2`? 

3. What is the value of `c3`? 

4. What is the value of `*p1`? 

5. What is the value of `*p2`? 

6. What is the value of `*p3`? 

*Explanation:*

- `p1 = &c2` sets `p1` to point to `c2`.
- `p2 = &c3` sets `p2` to point to `c3`.
- `p3 = &c1` sets `p3` to point to `c1`.
- `*p1 = *p2` assigns the value of `c3` (7) to what `p1` points to, which is `c2`. So, `c2` becomes `7`.
- `p2 = p3` makes `p2` point to what `p3` points to, which is `c1`.
- `(*p2)++` increments the value of what `p2` points to (`c1`), increasing it from `3` to `4`.
- `*p3 = *p1 + *p2` sets `c1` to the sum of the values that `p1` (`c2`) and `p2` (`c1`) point to, so `c1 = 7 + 4 = 11`.
- `p2 = &c2` makes `p2` point to `c2` again.
- `c2 = c3 + *p1` sets `c2` to `c3 (7)` plus the value that `p1
Transcribed Image Text:Given the following program, fill in the blanks resulting from the `cout` statements: ```cpp int c1 = 3; int c2 = 5; int c3 = 7; int* p1; int* p2; int* p3; p1 = &c2; p2 = &c3; p3 = &c1; *p1 = *p2; p2 = p3; (*p2)++; *p3 = *p1 + *p2; p2 = &c2; c2 = c3 + *p1; ``` 1. What is the value of `c1`? 2. What is the value of `c2`? 3. What is the value of `c3`? 4. What is the value of `*p1`? 5. What is the value of `*p2`? 6. What is the value of `*p3`? *Explanation:* - `p1 = &c2` sets `p1` to point to `c2`. - `p2 = &c3` sets `p2` to point to `c3`. - `p3 = &c1` sets `p3` to point to `c1`. - `*p1 = *p2` assigns the value of `c3` (7) to what `p1` points to, which is `c2`. So, `c2` becomes `7`. - `p2 = p3` makes `p2` point to what `p3` points to, which is `c1`. - `(*p2)++` increments the value of what `p2` points to (`c1`), increasing it from `3` to `4`. - `*p3 = *p1 + *p2` sets `c1` to the sum of the values that `p1` (`c2`) and `p2` (`c1`) point to, so `c1 = 7 + 4 = 11`. - `p2 = &c2` makes `p2` point to `c2` again. - `c2 = c3 + *p1` sets `c2` to `c3 (7)` plus the value that `p1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage