NEW
Font size
WorksheetsC++ Programming Quiz
Total questions: 42
Worksheet time: 21mins
Which class should be included to work with files?
Which of the following is the valid array declaration?
int arr(10);
int arr[10];
array int[10];
int [10] arr;
If the type specifier of parameters of a function is followed by &, that function call is…
Call by value
Call by pointer
Call by reference
Call by address
Which gives the memory address of a pointer pt1?
*pt1
&pt1
pt1
**pt1
Which libraries should be included to get string in a file?
How to implement array of chars with 10 elements?
char a;
char a(10);
char a[10];
string a[10];
How to get whole string in one line (command line)?
cin >> str;
gets()
getline(cin, str);
scanf()
How to get whole string in one line (in file)?
cin >>
getline(file, str);
file >> str;
read()
Why do we need library
Console I/O
String handling
File handling
Memory allocation
What does this mean: int (*fp)(char*) ?
Pointer to int
Function returning pointer
Pointer to function
Array of functions
Operator used for dereferencing is
&
*
->
.
Choose the right option: string* x; string y;
Both pointers
x pointer, y variable
x variable, y pointer
Both variables
Mandatory parts in function declaration are
Function name
Return type
Parameters
Return type and function name
Which is used to terminate function declaration?
:
.
;
}
Operator used for input stream is
<<
>>
<>
=
Which correctly declares an array?
int a[] = 10;
int a[10];
int a(10);
array a[10];
Index number of last element of array with 9 elements
9
1
8
0
What is an array?
Single variable
Collection of different types
Collection of same type elements
Pointer
Which accesses the 7th element of array a?
a[7]
a[6]
a(7)
a[8]
Constants are also called as
Variables
Literals
Identifiers
Keywords
Parts of literal constants are
Integer only
Integer and float
Numeric, character, string
Boolean only
How constants are declared?
int x;
const int x;
constant int x;
final x;
Inline function is expanded inline at
Compile time
Run time
Link time
Execution time
If argument is declared as const, then
It can be modified
It cannot be modified
It must be global
It must be static
C++ appends what at end of string literal?
\n
\0
EOF
Space
Pointer P stores address of value. Which prints value?
P
&P
*P
**P
Function calling itself is called
Inline
Overloaded
Recursive
Virtual
int divide(int a, int b = 2) means
Function overloading
Default argument
Inline function
Recursion
Variables inside parentheses of function have
Global access
Static access
Local access
Public access
Last index of string contains
Space
Newline
\0
Last character
const int pathwidth = 100; means
Variable
Pointer
Constant integer
Macro
By default files are opened in
Write mode
Append mode
Read mode
Binary mode
What punctuation ends most C++ lines?
.
:
;
,
Which is not a correct variable type?
int
float
real
char
Unique function where execution starts
start()
main()
begin()
init()
Which cannot be used in identifiers?
Letter
Digit
Underscore
Space
Which is not a valid escape code?
\n
\t
\z
\0
To increase value of c by one, which is wrong?
c++
++c
c = c + 1
c + 1
b=3; a=b++; result is
a=4, b=4
a=3, b=4
a=4, b=3
a=3, b=3
Result of relational operation is always
Integer
Float
Boolean
Character
Looping means
Program termination
Repetition of statements
Function call
Conditional check
If parameter uses &, function call is
Call by value
Call by pointer
Call by reference
Call by copy
