Question

PART 2: BLUE BOOK I TO VI ANSWER THESE IN THE BLUE BOOK SHOW ALL WORK for full credit IF NECESSARY (10 pts): Show the program trace IN A TABLE OF VALUES AND OUTPUT of the following using the input stream 5 2-1 10 int A, B, N; A 3; B-6; cout<<Enter a sequence of values do cin >> N A=A+N+B; J while (N< 10) B *= 2; cout << (NAB) = << ( << N << , << A << , << B << )くくendl; return 0;
0 0
Add a comment Improve this question Transcribed image text
Answer #1

NOTE: I have completed the program for your assignment. Please check and let me know if you have any questions. I will acknowledge back with a response within 24 hours. Thanks for your patience.

I have pasted below a table containing program statements and change in variable values based on statement execution. The bolded statements are copied for easy understanding of execution of the code but really code will not duplicate and extend lines of code.

Output of the program is:
Input:- Enter a sequence of values 5 2 -1 10   
Output:- (N, A, B) = (10,49,20)

Table of Statement and change in Variable values during program execution:-

Statement N A B Comments
int A, B, N;
    A = 3; 3
    B = 6; 3 6
    cout << "Enter a sequence of values ";
    do{
        cin >> N; 5 3 6 for input 5
        A = A + N + B; 5 14 6
        B++; 5 14 7
        cin >> N; 2 14 7 for input 2
        A = A + N + B; 2 23 7
        B++; 2 23 8
        cin >> N; -1 23 8 for input -1
        A = A + N + B; -1 30 8
        B++; -1 30 9
        cin >> N; 10 30 9 for input 10
        A = A + N + B; 10 49 9
        B++; 10 49 10
    }while (N < 10); 10 49 10
    B *= 2; 10 49 20
    cout << "(N, A, B) = "<<"("<< N << "," << A << "," << B << ")" << endl; 10 49 20

Explanation:-
1) The initial values of A is 3 and B is 6
2) The do-while loop reads a sequence of values 5 2 -1 10 in the loop
3) In each iteration the value of A and B changes and is depicted clearly in the above table
4) Once the program comes out from do-while loop the value of (N, A, B ) is (10, 49, 10)
5) With the execution of statement B*=2 the value of B changes from 10 to 20
6) Hence the final values of (N, A, B) is (10, 49, 20)

Add a comment
Know the answer?
Add Answer to:
PART 2: BLUE BOOK I TO VI ANSWER THESE IN THE BLUE BOOK SHOW ALL WORK...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Part #2 Trace and show your steps and the output of the following code segment const...

    Part #2 Trace and show your steps and the output of the following code segment const int TEN = 10; int a(TEN), n = 354, num, c = 0; num = n; a[C++] = num % TEN; num = num/TEN; } while (num); cout << "The number" <<n<<" is now: for (int k = -1;k >= 0; k--) cout << a[k]; cout << endl; Trace and show the content of the arrays A and B int A[7] = {66, 55,...

  • 5. (6 pts) What is the outputs of following section of a program? int a[10] =...

    5. (6 pts) What is the outputs of following section of a program? int a[10] = {1,2,3,2, 5, 6, 7, 8 , 9, y): int i - 0, 30: while (i<10) coutくく3くくendl ; 6. (6 pts) What is output of following set of instructions in a C++ program: (In this problem both x and y represent positive integers) int a[10]={-1, 3=0; 2, 7, -4, 11, -2, 3, -9); x, -y, int for (int i-0:i<10:i++) if (a [1]<0) s+ai] coutくく3(くend-; 7....

  • points): Show the output of the code below as it would appear on the monitor. int...

    points): Show the output of the code below as it would appear on the monitor. int main cout <<" <<endl: int wildcat 2: while (wildcat > 5) cout << wildcat <<endl; wildcat++ cout <K*<< endl; int jayhavk 5i do cout << jayhawk <s endl: while (jayhawk0) cout <<*" << endl; int wolverine l: while (wolverine 0 &&wolverine < 10) cout << wolverine <<endl: wolverine2: cout <<" <<endl: for (int zag-4; zag>0; zag_) cout <<****" << endl; for (int i-10; i<-30;...

  • How many Iterations will this while loop perform? int ico), j(10); cout << "i = "...

    How many Iterations will this while loop perform? int ico), j(10); cout << "i = " << i << endl; cout << "j = " << j << endl; while (i > j) { cout << "j-" « j << endl; j += 2; cout << "i = " << i << endl; } cout << "i = << i << endl; cout << "j = " << j << endl; 5 6 C 8 10 Infinite times Does the...

  • Flow CHART READ THIS PROGRAM OVER SEVERAL TIMES vI: Flow chart the problem that follows. DO...

    Flow CHART READ THIS PROGRAM OVER SEVERAL TIMES vI: Flow chart the problem that follows. DO NOT WRITE THE CODE. Your grade will depend on how well you show cosmology the behavior of space through time is given by a function called the scale factor r(t). The variable,t, i behaviors of the scale factor depending upon estimates of the amount of matter in the universe. The amount of rogrom will start by asking the user for the epsilon value only...

  • IV. Function Tracing (20 points) Trace the following program. Show llof your work and the ound...

    IV. Function Tracing (20 points) Trace the following program. Show llof your work and the ound he output in the work including labeled boxes for user-defined functions, calculations, and the output in designated spaces. You should draw a box for each variable and show value updates d the output, Show all of your #include <iostream» using namespace std; void mickey (int sa, int b, int &c) void minnie(int u, int &v, int w); void pluto (int m, int n, int...

  • C++ Object Oriented assignment Can you please check the program written below if it has appropriately...

    C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...

  • Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const...

    Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6,19,5,3,2,17,40,90,19,80) float ary2tsiz)-to int i,x x-ffx(aryl,ary2, ,siz): cout<<"n The values are: for(1-0:1<" ; it) ary2[i] ; cout<<" coutくくendl ; return 0; oerio int ffx(float all,float bll, int S) int i,p-0; for(i 0: i<s ; i++){ )// end for LD++]=a[i]; return p; if(ifp(ali])) bool ifp(int n)l bool ans-true for (i=2:ic, itt)...

  • Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6...

    Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6,19,5,3,2,17,40,90,19,80) float ary2tsiz)-to int i,x x-ffx(aryl,ary2, ,siz): cout<<"n The values are: for(1-0:1<" ; it) ary2[i] ; cout<<" coutくくendl ; return 0; oerio int ffx(float all,float bll, int S) int i,p-0; for(i 0: i<s ; i++){ )// end for LD++]=a[i]; return p; if(ifp(ali])) bool ifp(int n)l bool ans-true for (i=2:ic, itt)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT