BOOK EXERCISES (BASIC ELEMENTS OF C++) Flashcards
Mark the following statements as true or false.
An identifier can be any sequence of digits and letters.
false
Mark the following statements as true or false.
In C++, there is no difference between a reserved word and a pre-defined identifier.
false
Mark the following statements as true or false.
A C++ identifier can start with a digit.
false
Mark the following statements as true or false.
The operands of the modulus operator must be integers.
true
Mark the following statements as true or false.
If a = 4; and b = 3;, then after the statement a = b; the value of b is still 3.
true
Mark the following statements as true or false.
In the statement cin»_space; y;, y can only be an int or a double variable.
false
Mark the following statements as true or false.
In an output statement, the newline character may be a part of the string.
true
Mark the following statements as true or false.
The following is a legal C++ program:
int main()
{
return 0;
}
true
Mark the following statements as true or false.
In a mixed expression, all the operands are converted to floating-point numbers.
false
Mark the following statements as true or false.
Suppose x = 5. After the statement y = x++; executes, y is 5 and x is 6.
true
Mark the following statements as true or false.
Suppose a = 5. After the statement ++a; executes, the value of a is still 5 because the value of the expression is not saved in another variable.
false
Which of the following are valid C++ identifiers?
a. myFirstProgram b. MIX-UP c. C++Program2 d. quiz7
e. ProgrammingLecture2 f. 1footEquals12Inches
g. Mike’sFirstAttempt h. Update Grade i. 4th
j. New_Student
a, d, e, j
What is the difference between a reserved word and a user-defined identifier?
reserved words (int, float, void, return) can’t be redefined in the program, whereas user defined identifiers can be redefined
Which of the following is a reserved word in C++?
a. Const b. include c. Char d. void e. int f. Return
b, d, e
Are the identifiers firstName and FirstName the same?
NOPE
The identifiers firstName and FirstName are not the same. C++ is case-sensitive. The first letter of firstName is lowercase f, whereas the first character of FirstName is uppercase F. So these identifiers are different