HW#3 - When I actually tried this code in dev c the program executed successful but it would immediately close the window so as not to show the

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
David Carothers 10/3/07 CS 230 Homework #3 3. What is the output of the following code: Int x; Int y; Int *p = &x; Int *q = &y; *p = 35; *q = 98; *p = *q; Cout << x << "_" << y << endl; Cout << *p << "_" << *q << endl; Output: 98_98 98_98 4. What is the output of the following code? Int x; Int y; Int *p = &x; Int *q = &y; X = 35; Y= 46; P = q; *p = 78; Cout << x << "_" << y << endl; Cout << *p << "_" << *p << endl; Output: 35_78 78_78 9. What is the output of the following code? Int x; Int *p; Int *q; P = new int[10]; Q = p; *p = 4; For ( int j = 0; j < 10; j++) { X = *p;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
P++; *p = x + j; } For (int k = 0; k < 10; k++) { Cout << *q << " "; Q++; } Cout << endl; Output: From the loop presented I believe that there is a string of numbers presented.
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: When I actually tried this code in dev c++, the program executed successful but it would immediately close the window so as not to show the results. 10. What is the output of the code? Int *secret; Int j; Secret = new int[10]; Secret[0] = 10; For (j = 1; j < 10; j++) Secret[j] = secret[j-1] +5; For (j = 0; j < 10; j++) Cout << secret[j] << “ “; Cout << endl; Output: 10 15 20 25 30 35 40 45 50 11. Explain the difference between a shallow copy and a deep copy of data. Shallow copy is when 2 pointers point to the same data in a memory location whereas, the deep copy is the same data in a second location, making two copies....
View Full Document

This note was uploaded on 02/21/2012 for the course COMPUTER CS 230 taught by Professor Idk during the Spring '12 term at Capitol College.

Page1 / 2

HW#3 - When I actually tried this code in dev c the program executed successful but it would immediately close the window so as not to show the

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online