NEW
Font size
WorksheetsC++ Programming
Total questions: 20
Worksheet time: 15mins
Directives are translated by the
Pre-processor
Compiler
Linker
Editor
What will the result of 'num' variable after execution of the following statements?
int num = 58;
num % = 11;
3
5
8
11
What will the result of num1 variable after execution of the following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
11
12
13
14
Give the following declarations and an assignment statement. Which one is equivalent to the expression str [4]?
char str[80];
char * p;
p = str;
p + 4
*p + 4
*(p + 4)
p[3]
What output is produced by the following segment of code:
for(int i = 0; i < 10; i++)
cout << i << " ";
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
Infinite Loop
True/False: For Loops can never be an infinite loop.
True
False
How many times will the shown for loop execute?
0
9
10
11
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
What is the only function all C++ programs must contain?
cout()
system()
main()
program()
What punctuation is used to signal the beginning and end of code blocks?
{ }
//
BEGIN and END
/* */
Which of the following is a correct comment?
*/ Comments */
** Comment **
/* Comment */
{ Comment }
Which command moves the shown text to the next line?
\t
\n
\r
/n
After running the following code, what will be the value of x?
y = 3;
x = 5 * (++y);
15
5
15
20
Do while loops
Runs a statement once
Runs a statement twice
Runs a statement multiple times or not within a boolean condition
Doesn't run at all
Switch Statement
Is a statement with a set of conditions called cases
Is a case
Is a condition with no cases
Is a boolean statement
Voids
A statement that returns a value
A statement that doesn't return a value
A function that return a value
A function that doesn't return a value
iostream
Displays output from the screen and input from the keyboard
Has all the math equations
Counts the time
Checks if the code has a function
Cpp Compiler converts source code in
.cpp file
.obj file
.exe file
.lnk file
In a class the access specifiers are _______ by default:
Private
Protected
Public
What is the difference when allocating the following memory?
int array1[15];
int array2[3][5];
array1 is larger
array2 is larger
The size allocated is the same
