1. State whether each of the following is true or false. If false explain why.
a. 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.
b. All the variables must be given a type when they are declared.
c. Declarations can appear almost anywhere in the body of a C++ program.
d. The modulus operator(%) can be used only with integer operands.
e. A C++ program that reads three variables must contain three statements using cin and the stream extraction operator(>>).
a. False
Escape sequence "\n" tells the cursor to move on the next line.
b. True
C++ is a strongly-typed language, and requires every variable to be declared with its type before its first use. This informs the compiler the size to reserve in memory for the variable and how to interpret its value.
suppose we declare a variable
a; but we cant delare it like this in C++..correct sytex is below:
int a; (we simply write the type followed by the variable name)
c. True
d. True
e. False
No need to write three statement as we can write it like
cin >> a >> b ;
which is equal to
cin >> a;
cin >> b;
Extractions on cin
can also be chained to request
more than one data in a single statement:
Thanks
Get Answers For Free
Most questions answered within 1 hours.