WorksheetsC++ Quiz
Total questions: 50
Worksheet time: 37mins
Suppose x is 5 and y is 7. Choose the value of the following expression:
(x != 7) && (x <= y)
false
1
0
null
Suppose that x is an int variable. Which of the following expressions always evaluates to true?
(x > 0) || ( x <= 0)
(x >= 0) || (x == 0)
(x > 0) && ( x <= 0)
(x > 0) && (x == 0)
Which of the following expressions correctly determines that x is greater than 10 and less than 20?
10 < x < 20
(10 < x < 20)
10 < x && x < 20
10 < x || x < 20
The expression in an if statement is sometimes called a(n) ____.
selection statement
action statement
decision maker
action maker
What is the output of the following C++ code?
int x = 35;
int y = 45;
int z;
if (x > y)
z = x + y;
else
z = y – x;
cout << x << " " << y << " " << z << endl;
35 45 80
35 45 10
35 45 –10
35 45 0
When one control statement is located within another, it is said to be ____.
blocked
compound
nested
closed
Which of the following will cause a logical error if you are attempting to compare x to 5?
if (x == 5)
if (x = 5)
if (x <= 5)
if (x >= 5)
Assume you have three int variables: x = 2, y = 6, and z.
Choose the value of z in the following expression: z = (y / x > 0) ? x : y;.
2
3
4
6
What is the value of x after the following statements execute?
int x;
x = (5 <= 3 && 'A' < 'F') ? 3 : 4
2
3
4
5
Which of the following refers to a temporary storage that can be assigned a value within a program?
value
data type
function
variable
In C++ programming, which type of controlling position performs new line command?
elnd
end
endl
end()
What is the output of the given value expression?
float n = 4.6, x=11.33,y;
y=n+x;
cout << y;
15.93
15.10
15.0
15
Which of the following reads the entire program and converts it into object code?
editor
compiler
interpreter
debugger
In C++, which of the following defines the routines for standard input and output, such as cout and cin?
#include<conio.h>
#include<math.h>
#include<stdio.h>
#include<iostream>
Which symbol is used when storing a character in a variable?
" "
' '
;
:
what does this shape represent in a flowchart?
input/output
process
decision
flowlines
What is the name of this symbol in a flowchart?
flowlines
input/output
decision
process
what flowcharting symbol should the equation below be placed?
a = num%2
He is the developer of c programming
bjarne stroustrup
dennis ritchie
ken thompson
brian kernighan
He is the developer of C++ programming language
bjarne stroustrup
ken thompson
dennis ritchie
brian kernighan
which of the following is the format specifier for char items [100] when you want to display/output it?
%c
%s
%i
%f
which of the following data types that specifies no value is returned/available?
integer
void
boolean
float
what is the function used in c programming that displays the output on the terminal window.
printf
cout
cin
scanf
It is a function in c++ programming used to display the output on the terminal window.
cin
cout
printf
scanf
It is a data type that can contain data with decimal numbers.
integer
char
float
boolean
It is also called a procedure or a function that is used to perform a certain task
flowchart
algorithm
pseudocode
data flow diagram
what is the output of this equation,10 + 23/2%2+100 -25
86
15
75
81
give the output of 6 * (2 / 15% 3) + 354 -125
-125
175
-176
229
What is the value of X in the sample code given below?
X = ( 2 + 3) * 2 + 3;
10
13
25
28
What value will be stored in z if the following code is executed?
x = 5 , y = -10, a = 4, b = 2;
z = x+++++y * b/a;
-2
2
1
0
Evaluate the following expressions to true or false
5 >= (1+6)-4
true
false
Which operators are used to compare the values of operands to produce logical value in C language
mathematical
logical
relational
assignment
Determine if the statement below is correct:
double x, y;
cout <<"Enter a number: ";
cin>>y;
x=y+1;
cout<<"\nDisplay Input plus 1....";
true
false
Determine if the statement below is correct:
char let1 = 't';
char let2 = 'i';
char let3 = 'p';
cout<<let1, let2, let3;
true
false
Determine if the statement below is correct:
int x;
cout<<“Enter a number: ”; cin>>x;
true
false
Determine the variable below whether it is valid or not:
NAME
valid
invalid
Determine the variable below whether it is valid or not:
sumof3Numbers
valid
invalid
Determine the variable below whether it is valid or not:
aver@ge
valid
invalid
Determine the variable below whether it is valid or not:
first name
valid
invalid
Determine the variable below whether it is valid or not:
Char34
valid
invalid
Determine the variable below whether it is valid or not:
int
valid
invalid
What is the output of the following program segment if the entered value for num = 1234?
main(){ int num, w,x,y,z;
scanf(“%d”,&num);
w = num % 10;
x = (num / 10) % 10;
y = (num/100) % 10;
z = num / 1000;
printf(“%d %d %d %d”, w,x,y,z); }
1234
1243
4321
4312
What part of your c program structure we prepare variables before using them inside the program?
main
declaration
output
conditional expression
Which type of controlling position that performs new line command?
//n
/n
\n
\*n
Which of the following literal may be in the form of a series of characters?
character
string
boolean
integer
What is the output of the code below:
mickey = mouse;
if (mickey == mouse)
cout << ("Mickey is a mouse");
else
cout << ("Minnie rules");
Mickey is a mouse
Nothing prints.
Minnie rules
Mickey is a mouse" & "Minnie rules
What is the output of the code below:
john = 5;
if (john > 6)
cout << ("John is getting ice cream");
else
cout << ("John is getting apple juice");
cout << "John is getting grapes")
John is getting ice cream
John is getting apple juice
John is getting grapes
John is getting apple juice
John is getting ice cream
Equivalent of switch statement
if
else if ladder
if else
while
What is the output of the code below:
number_of_coins = 10 .
if (number_of_coins == 6)
cout << "You can buy some gum";
else
if (number_of_coins == 10)
cout << "You are rich";
else
cout << "Get a job!";
You can buy some gum
You are rich
Get a job!
You are rich
Get a job!
Which of the following is a correct comment?
*/ Comments */
/* Comment */
** Comment **
{ Comment }
