CS201P Quiz 3 Spring 2023 Solved by Munir
Question # 1:
Macro is defined by which preprocessor directive?
Options:
a) #if
b) #endif
c) #define
d) #else
Correct Answer: c) #define
Question # 2:
What would be the output of the following statement? c = 13 % 2;
Options:
a) 3
b) 2
c) 0
d) 1
Correct Answer: d) 1
Question # 3:
Functions `seekg()` and `seekp()` require an argument of type ____ to let them know how many bytes to move forward or backward.
Options:
a) double
b) long
c) float
d) int
Correct Answer: b) long
Question # 4:
In C++, which of the following option is used to declare a class?
Options:
a) CLASS
b) cLAss
c) Class
d) class
Correct Answer: d) class
Question # 5:
A constructor with arguments is known as what?
Options:
a) Paramterized Constructor
b) Default Constructor
c) Destructor
d) Virtual Constructor
Correct Answer: a) Paramterized Constructor
Question # 6:
Where to put an inline function during frequent calling inside the program from multiple source files?
Options:
a) Outside the class
b) Main()
c) Header File
d) Inside the class
Correct Answer: c) Header File
Question # 7:
In bit manipulation of binary systems, if we shift a bit towards the right, then it means we are __________ that binary value with ‘2’.
Options:
a) Dividing
b) Multiplying
c) Adding
d) Subtracting
Correct Answer: a) Dividing
Question # 8:
In C++, the default visibility of a structure is ______.
Options:
a) Private
b) Protected
c) Pass
d) Public
Correct Answer: d) Public
Question # 9:
The bit manipulation operator used to set a specific bit is ___________.
Options:
a) &
b) *
c) ^
d) |
Correct Answer: d) |
Question # 10:
What will be the output of the following code segment?
```cpp
struct student{
int age;
float cgpa;
char name[20];
};
int main(){
student s = {21, 3.56, "Zaman"};
cout << sizeof(s);
}
```
Options:
a) 27
b) 28
c) 29
d) 30
Correct Answer: d) 30