Question

Answer the following five questions related to code output (Q2 i through m) What is the output of the following C+ coaer int numl; int num2; int *p = &num1 ; p = &num2 ; *p 25; num1 num2 + 6; p = &num! ; num2 = 73; *p = 47; cout << *p << << numl <<<< num2 << endl; What is the output of the following C++ code? int length; int *width; length = new int; * length = 5; width = length; length new int; * length= 2 * (* width); cout << *length <<<<width << << (*length) *(*width) << endl; What is the output of the following C++ code? int * first new int; int second; *first 85; second = first; *secondsecond + *first; first = new int; * first = * second - 100; cont << *first<< << * second << endl;Please help me solve the following. Thank you in advance :)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I) Initially p is pointing to num1 but then it points to num2
p changes value of num2 (as it points to it) to 25 i.e num2 = 25
num1 = 25 + 6 = 31 , num2 will be 73 and num1 . will be 37 as p is pointing to num1 now
So, final Output is 37 37 73


II)
10 5 50

length is 5 so width also points to same location, then length gets new memory location and assigns 2*5 = 10


III)*second = 160 , then *first = 60

So, final Output is 60 160


IV) Initally the array will contain
8 10 12 14 16

temp will change the list and increment each element by 3

11 13 15 17 19

So, final Output is 11 13 15 17 19


V)
IV) Initally the array myList will contain
3 4 6 9 13

YourList = 7 8 10 13 17 10 6 3 1 0


So, final Output is myList = 3 4 6 9 13
So, final Output is YourList = 7 8 10 13 17 10 6 3 1 0




Add a comment
Know the answer?
Add Answer to:
Please help me solve the following. Thank you in advance :) Answer the following five questions...
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
  • 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...

  • Please answer both questions thank you. Assuming that a user enters 8, 15, and 11 as...

    Please answer both questions thank you. Assuming that a user enters 8, 15, and 11 as input values one after another, separated by spaces, what is the output of the following code snippet? int num1 = 0; int num2 = 0; int num3 = 0; Scanner in = new Scanner (System.in); System.out.print("Enter a number: "); numl - in.nextInt(); System.out.print("Enter a number: "); num2 = in.nextInt(); System.out.print("Enter a number: "); num3 = in.nextInt(); if (numl > num2) if (numl > num3)...

  • NEED ASAP PLEASE HELP Task: --------------------------------------------------------------------------------------...

    NEED ASAP PLEASE HELP Task: --------------------------------------------------------------------------------------------------------------------------------- Tasks to complete: ---------------------------------------------------------------------------------------------------------------------------------------- given code: ----------------------------------------------------------------------------------------------------------------------------------------------- main.cpp #include <iostream> #include <iomanip> #include "fractionType.h" using namespace std; int main() { fractionType num1(5, 6); fractionType num2; fractionType num3; cout << fixed; cout << showpoint; cout << setprecision(2); cout << "Num1 = " << num1 << endl; cout << "Num2 = " << num2 << endl; cout << "Enter the fraction in the form a / b: "; cin >> num2; cout << endl; cout <<...

  • Question 4 20 pts Go to the full description for No.42 Consider the following code. Show...

    Question 4 20 pts Go to the full description for No.42 Consider the following code. Show the expected result of this program and Explain the reason why each variable shows such a value. Draw the memory layout after the variable declaration and line 10. [20pts] Tinclude <iostream> using namespace std; int main() int int num1 = 1; num2 = 20; ref1 = num; refi = num; cout << "Refl " << refl << "numl" << nunl << "num2 " <<...

  • C++ problem where should I do overflow part? in this code do not write a new...

    C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...

  • SEE THE Q3 for actual question, The first Two are Q1 and Q2 answers . Q1...

    SEE THE Q3 for actual question, The first Two are Q1 and Q2 answers . Q1 #include<iostream> using namespace std; // add function that add two numbers void add(){    int num1,num2;    cout << "Enter two numbers "<< endl;    cout << "First :";    cin >> num1;    cout << "Second :";    cin >>num2;    int result=num1+num2;    cout << "The sum of " << num1 << " and "<< num2 <<" is = "<< result;   ...

  • Please answer both questions thank you. Question 49 (1 point) What is wrong with the following...

    Please answer both questions thank you. Question 49 (1 point) What is wrong with the following code snippet? for (int i 1; i <= 5; i++) { int squared = i + i; System.out.println(i + IT "! squared = + squared); } System.out.println("Last square = " + squared); calculation error variable scope error O nothing incorrect use of for loop Question 47 (1 point) What are the values of num1 and num2 and result after the execution of mystery (num1,...

  • Please show all steps for #15 and #16 neatly. Thank you so much in advance! Will...

    Please show all steps for #15 and #16 neatly. Thank you so much in advance! Will rate thumbs up for correct answer ! ? 15. Determine the output of th ollowing Ct+ code? int num346, sum 0; do wA sum-sum + num % 10; num = num / 10; cout < sum endl; while (num> e); rmine the output produced by the following code fragment? int i 11; i 1 i 4)10 9 cout << i << " ". i+t;...

  • Please answer in plain text. Determine the C++ output for the following: Assume: int num1 =...

    Please answer in plain text. Determine the C++ output for the following: Assume: int num1 = 25,   num2 = 5,   num3 = 10;          a.    cout<< “ The product is “ << num1 * num3;                 ________________________________________________________ b.     cout<< “ The total of the three numbers is: “ <<(num1+num2+num3);          ________________________________________________________ c.     cout<< “ The total is: “ <<(num1+254.3373);                 _________________________________________________________ d.     cout << num1 << “ +  “    << num2 << “ = ” << num1 + num2;                _________________________________________________________ e.    cout << “ This is how the output...

  • It's a C++ code. 2. Answer the following questions in a word document. 6. What is...

    It's a C++ code. 2. Answer the following questions in a word document. 6. What is the output of the following C++ code? (2, 3) int inti - 26 int int2 = 45; int intPtr - Einti; int int2Ptr - Gint2: intPtr -89; int2Ptr - 623 intiptr - int2Ptr intPtr - 80 intl -57 cout << inti «..« int2 << endl; cout << *intiptr «« int2Ptr << endl; 7. Given the following statements: int num; int numPtr write C++ statements...

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