Fill in the blanks in each of the following.
Every C++ program begins execution at the function _________.
The _________ begins the body of every function and the _________ ends the body of every function.
Every C++ statement ends with a(n) _________.
The escape sequence \n represents the _________ character, which causes the cursor to position to the beginning of the next line on the screen.
The _________ statement is used to make decisions.
State whether each of the following is true or false. If false, explain why. Assume the statement using std::cout; is used.
Comments cause the computer to print the text after the // on the screen when the program is executed.
The escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.
All variables must be declared before they are used.
All variables must be given a type when they are declared.
C++ considers the variables number and NuMbEr to be identical.
Declarations can appear almost anywhere in the body of a C++ function.
The modulus operator (%) can be used only with integer operands.
The arithmetic operators *, /, %, + and all have the same level of precedence.
A C++ program that prints three lines of output must contain three statements using cout and the stream insertion operator.
Write a single C++ statement to accomplish each of the following (assume that using declarations have not been used):
Declare the variables c, thisIsAVariable, q76354 and number to be of type int.
Prompt the user to enter an integer. End your prompting message with a colon (:) followed by a space and leave the cursor positioned after the space.
Read an integer from the user at the keyboard and store the value entered in integer variable age.
If the variable number is not equal to 7, print "The variable number is not equal to 7".
Print the message "This is a C++ program" on one line.
Print the message "This is a C++ program" on two lines. End the first line with C++.
Print the message "This is a C++ program" with each word on a separate line.
Print the message "This is a C++ program" with each word separated from the next by a tab.
Write a statement (or comment) to accomplish each of the following (assume that using declarations have been used):
State that a program calculates the product of three integers.
Declare the variables x, y, z and result to be of type int (in separate statements).
Prompt the user to enter three integers.
Read three integers from the keyboard and store them in the variables x, y and z.
Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.
Print "The product is " followed by the value of the variable result.
Return a value from main indicating that the program terminated successfully.
Using the statements you wrote in Exercise 2.4, write a complete program that calculates and displays the product of three integers. Add comments to the code where appropriate. [Note: You will need to write the necessary using declarations.]
Identify and correct the errors in each of the following statements (assume that the statement using std::cout; is used):
if ( c < 7 );
cout << "c is less than 7\n";
if ( c => 7 )
cout << "c is equal to or greater than 7\n";