

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This worksheet is for your use during and after lecture. It will not be collected or graded, but I think you will find it a useful tool as you learn C++ and study for the exams. Explain all false answers for the “True or False” questions; in general, show enough work and provide enough explanation so that this sheet is a useful pre-exam review. I will be happy to review your answers with you during office-hours, via Email, or instant messaging.
Solution: C
Solution: B
Solution: /* This is a comment */ and // This is a comment.
(b) Write the aforementioned comment across multiple lines in C++.
Solution:
/ ∗ T h i s i s a comment ∗ /
/ / T h i s / / i s a / / comment
Solution: False. Indentation is to help humans visualize the structure of program logic.
Solution: False. Comments and indentation are ignored.
Solution: False. Pre-processor directives “import” code from system libraries.
Solution: A, B, D, and E.
Solution: An identifier.
Solution: x3, SuperMan, mighty_mouse
Solution: 3x: numerals cannot begin variable names. CO2%: The percent sign is an invalid character for variable names.
double 3.14, -1, 0 , 32 int -3, 0 , 256 string "c", "word", or "a phrase of several words" bool true, false
Solution: The string type requires #include
Solution: bool truth( false ); or bool truth = false;.
Solution: int N( 3 ); or int N = 3;.
Solution: const double PI( acos(-1) ); or double PI = acos(-1);.
Mathematical Expression C++ Statement x^2 + y − (^1) z xx + y - 1/z √ 3 x − 4 y + (^) zyx sqrt( 3x - 4y) + x/(zy)
Page 2