1. In C++ the variables Alpha, ALPHA and AlphA are the same identifier.
2. C++ uses only /* */ for comments.
3. A program should have a comment on every line.
1. In C++, a legal identifiers may contain these kinds of characters __________, _________, _________
1. In C++, some of the following are legal identifiers. Which? Why?
a) 9xyz
b) Xyz
c) X+yz
d) xy_z
e) xyz!
2. Pick the C++ keywords out of the following list.
a) while
b) total_weight
c) double
d) if
e) number_of_bars
3. Before a variable in C++ is used, it must be
a) defined
b) initialized
c) used in some expression
d) begin with a capital letter
e) contain only letters, digits and underscores.
4. In C++, a variable that has been defined but not initialized may
a) be used in any way any identifier can be used.
b) not be used at all
c) have its value fetched prior to assignment.
5. Which of the following are legal definitions with initializations? (Consider each line to be in a different scope so there is no multiple definition of identifiers.)
a) int count = 0, limit = 19;
b) int count(0), limit(19);
c) int count = 0, limit(19);
d) int limit = 19;
e) int namespace(0);
6. Which of the following names might give the human reader some hint about the data that is stored in them?
a) aa, bb, cc
b) speed, distance, time
c) hypotenuse, leg1, leg2
d) v1, v2, v3
e) principal, interest, payment
7. The value of the expression 20.0 * (9/5) + 32.0 is
a) 68.0
b) 52.0
c) incorrect expression so there is no value
d) 32.0
e) incorrect expression , the / should be %
1. Given the C++ output statements. What is the output of these lines of code? Explain.
cout << "If you have ";
cout << "a number of pods ";
cout << "you can quit.";
cout << "\n";
2. What does the line #include <iostream> do for your program?
3. Write a C++ program that outputs "My first C++ program" and then outputs a carriage return.