assn5_soln - MIT OpenCourseWare http/ocw.mit.edu 6.096...

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

View Full Document Right Arrow Icon
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms .
Background image of page 1

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

View Full DocumentRight Arrow Icon
Part 1 1. The program first defines a structure data containing two variables z (of type float), and type (of datatype char). 2. In the main function, a structure type variable of the structure data is declared, and then initialized (D1.z is initialized to 20, and D1.type is initialized to P) 3. D1.z++ increments D1.z to 21, but since the increment is done by the post- increment operator, the cout prints 20, followed by ‘P’ (value stored in D1.type), on the screen. 4. A new structure type variable of structure data is declared. The value of D2.type is initialized to the value stored in D1.type (i.e P). The value of D2.z is initialized to 4 times the value stored in D1.z( i.e 21*4=84). 5. ++D2.z increments the value of D2.z by 1 (i.e to 85), and as the increment is done by the pre-increment operator, cout print 85 is on the screen, followed by ‘P’ (value stored in D2.type). 6. Finally, in the next line, D1.z is decremented by 1, but due to post-increment, its
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/14/2011 for the course DDDD h0322 taught by Professor Whoknow during the Spring '11 term at Bina Nusantara University.

Page1 / 6

assn5_soln - MIT OpenCourseWare http/ocw.mit.edu 6.096...

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

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