NEW
Font size
WorksheetsAlgo
Total questions: 56
Worksheet time: 28mins
1. Specify the types of operator
Logical, Bitwise, Arithmetic, Relational
Mathematical, Bitwise, Arithmetic, Relational
Assignment, Bitwise, Arithmetic, Relational
Logical, Bitwise, Assignment, Relational
2.When an equation uses more than one type of operator then the order of precedence has to be established with the different types of operators:
Comparison, logical, arithmetic
Arithmetic, comparison, logical
Logical, arithmetic, comparison
Arithmetic, logical, comparison
Logical operators always evaluated from
Right to left
Not sure
Left to right
No difference
4. Precedence for Logical Operators
OR, AND, NOT
NOT, AND, OR
AND, OR, NOT
OR, NOT, AND
What is an array?
An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier
An array is a series of elements of the different type placed in contiguous memory locations that can
be individually referenced by adding an index to a unique.
An array is a series of elements of the same type placed in contiguous memory locations that can be
When an array is partially initialized, the rest of its elements will automatically be set to zero
All of them
Nothing
False
True
The whole array can be passed to a function. However, it can't be changed by the code in that function
All of them
False
Nothing
True
What are the three steps in using a function?
Definition, prototype, invocation
Definition, invocation, argument
Prototype, argument, signature
9. write mpg() function prototype, that takes two type double arguments and returns a double
Double mpg(double a, double b)
Void mpg(){}
Float mpg(int a){ float b = 1; return b;}
Double mpg(int a, double b)
What is data structure?
is a group of data elements grouped together under one name
is a group of data elements grouped together under two names.
is a set of some elements grouped together under value
is a group of data elements together with some name.
The data elements in structure are also known as what?
Data
None of the above
Members
Objects
What will be used when terminating a structure?
Semicolon
Colon
Brackets
Dot
Which stream class is used to both read and write on files?
Ifstream
Ofstream
Fstream
Iostream
Which stream class is only used to read files
Ofstream
Ifstream
Iostream
Fstream
What is the difference between array and structure?
No difference
Only on their declaration
Structure can include members of different data types
Arrays can include only integers
What is the output from the following program code
10 10 10 10 10
11 11 11 11 11
0 1 2 3 4
10
The OR (||) operator
Has higher precedence that AND (&&) operator
Stops evaluation upon finding one condition to be true
True if all conditions are true
Associates from right to left
Which of the following for headers is not valid for C++ code?
for (int i = 0; i<7; i++)
for (int i = 0; i<8; i++)
for (integer i =0; j<10; i++);
for (int i = 0; i<9; i++)
There might be functions with the same name, but different arguments. The function called is the one whose arguments match the invocation. What is this mean?
Function overloading
Function overprocessing
Argument type error
Argument dispatch error
20. Which of the following cannot be used to create a random numbers?
structures
float
int
o none of the mentioned
Please evaluate !(1 && !(0 || 1)).
True
False
o Unevaluatable
o Not sure
What is the final value of x when the code int x; for(x=0; x<50; x++) {} is run?
10
50
0
51
How many times is a do while loop guaranteed to loop?
Infinitely
0
1
Variable
What is the output of the following code?
value
77.5
Float
Variable
Which of the following is a valid function call (assuming the function exists)?
funct;
funct x, y;
funct();
struct funct();
26. Which of the following is a complete function?
int funct();
int funct(int x) {return x=x+1;}
void funct[int] {cout&tl;<"Hello"}
void funct{x} {cout<<"Hello"}
Which of the following is required to avoid falling through from one case to the next?
End;
Break
Stop
A semicolon
Which of the following is the proper declaration of a pointer?
int x;
int &x;
int *x;
ptr x;
Which of the following gives the memory address of integer variable a?
*a;
a;
&a;
address(a);
Which of the following gives the memory address of a pointer a?
a;
*a;
&a;
address(a);
Which of the following gives the value stored at the address pointed to by the pointer a?
a;
val(a);
*a;
&a;
Which of the following gives the value stored at the address pointed to by the pointer ptr?
ptr;
val(ptr);
*ptr;
&ptr;
33. Which of the following accesses a variable in structure b?
b->var;
b.var;
b-var;
b>var;
Which of the following accesses a variable in structure mystruct?
mystruct ->var;
mystruct.var;
mystruct -var;
mystruct >var;
Which of the following correctly accesses the seventh element stored in diana, an array with 100 elements?
diana[6]
diana[7]
diana(7)
diana;
What is the correct way to write the condition y < x < z?
((y < x) && (x < z))
((y < x) || (x < z))
o ((y < x) & (x < z))
o ((y < x) AN (x < z))
37. The value 132.54 can represented using which data type?
Double
Void
Integer
Bool
In an assignment statement “ a=b; ” which of the following statement is true?
The variable a and the variable b are equal.
The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable
The value of variable a is assigned to variable b and the value of variable b is assigned to variable a.
The difference between while structure and do structure for looping is
In while statement the condition is tested at the end of first iteration
In do structure the condition is tested at the beginning of first iteration
The do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not
In while structure condition is tested beforeexecuting statements inside loop whereas in do structure condition is tested before repeating the statements inside loop
40. A function that calls itself for its processing is known as
Inline Function
Nested Function
Overloaded Function
Recursive Function
The keyword endl
Ends the execution of program where it is written
Ends the output in cout statement
Ends the line in program. There can be no statements after endl
Ends current line and starts a new line in coutstatement
Strings are character arrays. The last index of it contains the nullterminated character
\n
\t
\0
\1
43. Variables inside parenthesis of functions declarations have _____ level access
Local
Global
Module
Universal
44. Array indexing always starts with the number
0
1
-1
10
45. Which of the following accesses a variable in structure st1?
st1->var;
st1.var;
st1-var;
st1>var;
Which looping process is best used when the number of iterations is known?
For
While
Do-while
Nothing
If there is more than one statement in the block of a forloop, which of the following must be placed at the beginning and the ending of the loop block?
parentheses ( )
braces { }
brackets [ ]
arrows < >
A memory address is…
where a variable is stored.
where a variable is defined.
where a variable is declares
where a variable is print out.
The set of instructions that a computer will follow is known as..
program
variable
computer
brackets
cin >> number; is
an output statement
a colon
a variable
an input statement
51. cout << "How many items would you want?\n"; is
an output statement
a colon
a variable
an input statement
int number; is
an output statement
a variable declaration
a variable
an input statement
If x is 0, what is the value of (!x == 0)?
True
False
2
15
How to create array with n integers?
int n; cin >> n; int a = new# int[n];
int n; cin >> n; int& a; a = new int[n];
int n; cin >> n; int* a; a = new int[n];
int n; cin >> n; int a; a = new% int[n];
Which class should be included to work with files?
iostream
string
cmath
fstream
Which of the following is the output from the following C++ code?
15 14 13 12 11 10
15 14 13 12 11 10 9
9
15
