NEW
Font size
WorksheetsProgramming Quiz
Total questions: 19
Worksheet time: 10mins
What will be the output of the program?
Numbers read from file: 12345
Numbers read from file: 0
Unable to open file
Numbers read from file: 1 2 3 4 5
What is the difference between array and structure?
No difference
Structure can include members of different data types
Arrays can include only integers
Observe function declaration and choose the best answer: int divide(int a, int b = 2)
Variable b is international scope and will have value 2
Variable b is of integer type and will always have value 2
Variable a and b are of int type and initial value of both is 2
Variable b will have value 2 if not specified when calling function
Which of the following accesses a variable in structure b?
b=var;
b->var;
b.var;
Which of the following properly declares a variable var of structure foo?
var foo struct;
foo var;
instruct foo;
Struct foo;
How do you create an object of a structure?
Person person1 = {“Alice”, 30};
Person person1 = new Person();
Person* person1;
Person person1;
In an assignment statement a = b; which statement is true?
Changes in b affect a
Value of a is assigned to b
Value of b is assigned to a, later changes in b do not affect a
Variables are always equal
Which stream class is used to both read and write on files?
ifstream
iostream
ofstream
fstream
How many elements does this array have: int arraytwo[2][2];
2
1
4
8
The data elements in structure are also known as what?
Members
Data
None of the above
Objects
Which operator is used to compare two variables?
+=
&&
==
||
Write correct function prototype: Function takes integer argument number and returns double.
int intToDouble(number);
double intToDouble(int number);
float intToDouble(int number);
double intToDouble(double number);
Body of factorial function:
n! = n*(n+1)!
n! = n-(n-1)!
n! = n/(n-1)!
if(n>1) return n*factorial(n-1); else return 1;
What will be the output of the code (recursive array sum)?
15
10
5
20
This statement breaks one iteration in the loop:
break
continue
&&
Why do we need fstream class?
Mathematical functions
To work with files
To work with strings
We declare a function with _____ if it does not have return type.
void
float
int
bool
double
What is a recursive function?
Runs indefinitely
Cannot return value
Calls itself
Calls other functions
A function that calls itself for processing is known as:
Recursive function
Inline function
Overloaded function
Nested function
