Font size
WorksheetsC++ Basics
Total questions: 40
Worksheet time: 20mins
What is the only function that all C++ programs must contain?
start()
system()
main()
program()
Which command in C++ moves the text to the next line?
\t
\n
\r
\s
C++ was developed by?
What is the extension of C++ programs?
.c
.css
.cpp
.jsp
Which syntax is correct in printing an output in a C++ program?
print<<"Good Day!";
cout<<"Good Day!";
printf<<"Good Day!";
cout<<"Good"<<"Day!";
Insertion operator (<<) is used with?
cin
cout
both of the above
main
Which operators are used in C++?
==
+=
**
++
Boolean variable is declared with (a) keyword
break() is used along which statements
while
switch
for-while
if-then-else
I liked the quiz?
Yes
No
Maybe
Any suggestions?
This is a code that has not yet been linked into a complete program.
Source Code
Assembly Code
Object Code
Machine Code
The object code is produced in what program development phase?
Preprocessing
Compilation
Linking
Loading
Executing
What happens first when a C++ executable is run?
The preprocessor converts the source code into an object code.
The compiler converts the object code into an executable code.
The linker links the object code with the missing functions needed to produce the executable code.
The loader places the program in the memory
The CPU executes the program
By default, how are instructions executed by the CPU?
One instruction a a time
Several Instructions at a time
All instructions in one time
None of the above
Single line comments are denoted by what symbol?
//
\\
/*
*/
Which of the following are ignored by the C++ compiler and the computer? Check all that applies.
Comments
Blank lines
Spaces
Tab Spaces
Preprocessing directives
A preprocessing directive starts with what symbol?
//
#
(
{
The library defined in the preprocessor directive must be enclosed by what symbols?
{ }
[ ]
< >
( )
Blanks lines, spaces, and tab characters are called?
Keywords
White spaces
Symbols
Escape Sequences
A code that is reserved by C++ for a specific use.
Keyword
White space
Symbol
Escape Sequence
Which symbol starts a block of code?
<
(
{
[
The words enclosed in double quotation marks are known as the following EXCEPT what?
String
Character String
String Literal
Stream
The semicolon (;) is used to?
Start a block of code
Terminate a function
Start a statement
End a statement
Which of the following is the scope resolution operator?
<<
>>
::
\
Which of the following is the escape character operator?
<<
>>
::
\
Which of the following is the input stream object?
>>
<<
cin
cout
Which of the following is NOT a VALID identifier?
X1
_X1
x1
_1x
1x
Which of the following are VALID identifiers?
int
include
return
zero
All variables must be declared before they are used.
True
False
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
What punctuation is used to signal the beginning and end of code blocks?
{ }
-> and <-
BEGIN and END
( and )
Which of the following is a correct comment?
*/ Comments */
** Comment **
/* Comment */
{ Comment }
y = 3;
x = 5 * y;
Program
int main()
{
cout<<"Hi everybody";
return 0;
}
Which of the following is NOT a logical operator in C++ language?
&
&&
||
!
Which of the following is NOT a comparison operator in C++ language?
>
<=
=
==
If originally x=2,y=0, and z=1, what is the value of x, y, and z after executing the following code?
if (x>y)
y=x;
else
z=x;
x=2 y=2 z=1
x=0 y=2 z=0
x=2 y=1 z=1
x=2 y=0 z=1
