Considering the c++ program below, and [4, 5, 8, 3] as user inputs, answer the following questions: 1. Identify what is stored in the text segment when the process is admitted by the OS and is in the ready state. 2. Identify what variables will be stored in the data segment. 3. Identify what is stored in heap and stack segments when line 12 is being executed for the third time. 4. Identify what is stored in heap and stack segments when line 33 is being executed.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 4PP: (Numerical) Write and test a function that returns the position of the largest and smallest values...
icon
Related questions
Question

Considering the c++ program below, and [4, 5, 8, 3] as user inputs, answer the following questions:
1. Identify what is stored in the text segment when the process is admitted by the OS and is in the ready
state.
2. Identify what variables will be stored in the data segment.
3. Identify what is stored in heap and stack segments when line 12 is being executed for the third time.
4. Identify what is stored in heap and stack segments when line 33 is being executed. 

1 #include <iostream>
2 using namespace std;
3
4 int size = 4;
5
6 int sum(int n)
7 {
8
9
10
11
12
13}
14
15 int main()
16 {
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
static int result = 0;
result += n;
return result;
34
35
36}
int *p;
int i = 0;
p = new int[size];
int total = 0;
for (i = 0; i < size; i++)
{
}
cout << "enter number " << { + 1
cin >> p[i];
total
sum(p[i]);
te p;
cout<<"the final result is "<<total;
return 0;
♥
Transcribed Image Text:1 #include <iostream> 2 using namespace std; 3 4 int size = 4; 5 6 int sum(int n) 7 { 8 9 10 11 12 13} 14 15 int main() 16 { 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 static int result = 0; result += n; return result; 34 35 36} int *p; int i = 0; p = new int[size]; int total = 0; for (i = 0; i < size; i++) { } cout << "enter number " << { + 1 cin >> p[i]; total sum(p[i]); te p; cout<<"the final result is "<<total; return 0; ♥
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Properties of Different Architectures
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++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT