C++ Programming MCQ (Multiple Choice Questions) - SchoolingAxis

C++ Programming MCQ (Multiple Choice Questions)

 Que- When will the cin can start processing of input? 

a. After pressing return key 

b. BY pressing blank space 

c. After pressing return key & BY pressing blank space 

d. BY pressing delete space 


Answer- After pressing return key 


Que- Which is used for formatting purpose in c++? 

a. Whitespace 

b. Container 

c. & 

d. Vector 


Answer- Whitespace 


Que- How many number of spaces should be set in default tab? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 4 


Que- What can be improved by formatting the source code? 

a. Memory 

b. Address 

c. User interface 

d. Iterator 


Answer- User interface 


Que- Choose the correct formatted code. 

a. int a = 5; 

b. int a=5; 

c. int a =5; 

d. int a5; 


Answer- int a = 5; 


Que- Which function allows you to set minimum width for the next input? 

a. setfill 

b. setw 

c. setwidth 

d. setheight 


Answer- setw 


Que- What is the use of the function "showbase"? 

a. Indicate the base used 

b. Indicate the variable 

c. Indicate the base used & variable 

d. Indicate the derived 


Answer- Indicate the base used 


Que- Which operator is used to insert the data into file? 

a. >> 

b. << 

c. < 

d. > 


Answer- << 


Que- Which function is used to position back from the end of file object? 

a. seekg 

b. seekp 

c. both seekg & seekp 

d. seekf 


Answer- seekg 


Que- How many objects are used for input and output to a string? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which member function is used to determine whether the stream object is currently associated with a file? 

a. is_open 

b. buf 

c. string 

d. is_out 


Answer- is_open 


Que- Which header file is used for reading and writing to a file? 

a. #include<iostream> 

b. #include<fstream> 

c. #include<file> 

d. #include<fe> 


Answer- #include<fstream> 


Que- Which one is always faster in writing on C++? 

a. Writing to a file 

b. Writing to memory 

c. Reading from the network 

d. Deleting a file 


Answer- Writing to memory 


Que- How many tests are available in read and write operations? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- What will act as a intermediate between i/o operations and physical file? 

a. Memory 

b. Ram 

c. Stream buffer 

d. Storage 


Answer- Stream buffer 


Que- By using which function does the buffer are automatically flushed? 

a. fopen 

b. copy 

c. compare 

d. fclose 


Answer- fclose 


Que- How many parameters are available in the function setbuf? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- What is the main feature of locale in C++? 

a. Sustainability 

b. Portability 

c. Reliability 

d. Sustainability & Reliability 


Answer- Portability 


Que- Which objects information is loaded in locale object? 

a. facet object 

b. instead object 

c. Both facet & instead object 

d. secant object 


Answer- facet object 


Que- How many categories are available in facets? 

a. 4 

b. 5 

c. 6 

d. 3 


Answer- 6 


Que- What kind of locale does every program is having in C++? 

a. local locale 

b. global locale 

c. temp locale 

d. set locale 


Answer- global locale 


Que- What will the monetary facet will do? 

a. Handle formatting and parsing of monetary values 

b. Handle formatting and parsing of character values 

c. Parsing of character values 

d. Deleting a character values 


Answer- Handle formatting and parsing of monetary values 


Que- Which header file is used with input and output operations of C in C++? 

a. stdio.h 

b. cstdio 

c. iostream 

d. streamio 


Answer- cstdio 


Que- Which will be used with physical devices to interact from C++ program? 

a. Programs 

b. Library 

c. Streams 

d. Iterators 


Answer- Streams 


Que- How many streams are automatically created when executing a program? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- How many indicators are available in c++? 

a. 4 

b. 3 

c. 2 

d. 1 


Answer- 3 


Que- What is the benefit of c++ input and output over c input and output? 

a. Type safety 

b. Exception 

c. Both Type safety & Exception 

d. Sequence container 


Answer- Type safety 


Que- To which type does the numeric limits are suitable? 

a. Character types 

b. Mixed type 

c. Arithmetic types 

d. Relational types 


Answer- Arithmetic types 


Que- Where does the member should be defined if it is used in the program? 

a. Namespace scope 

b. Character scope 

c. Namespace & Character scope 

d. Directional scope 


Answer- Namespace scope 


Que- What will the max function in the numeric limit will return for type float? 

a. Maximum finite value for a float type 

b. Maximum finite value 

c. Minimum finite value 

d. Minimum float value 


Answer- Maximum finite value for a float type 


Que- Which header file is used for the numeric limits in C++? 

a. <iostream> 

b. <limits> 

c. <number> 

d. <digit> 


Answer- <limits> 


Que- Pick out the incorrect static function member in numeric limits. 

a. denorm_min 

b. digits 

c. infinity 

d. max_finite 


Answer- max_finite 


Que- With which does the trigonometric functions work with angles in c++? 

a. Degrees 

b. Radians 

c. Both Degrees & Radians 

d. Celsius 


Answer- Radians 


Que- Which header file is required for manipulation of math functions in c++? 

a. cmath 

b. maths 

c. math 

d. dmath 


Answer- cmath 


Que- How many macros are used by mathematical functions in the header file <cerrno>? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which of the following mathematical function is overloaded in <complex> and <valarray>? 

a. cos 

b. tan 

c. sin 

d. mod 


Answer- tan 


Que- How many parameters are used in frexp function? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- Which of the following library is used to do vector arithmetic? 

a. Boost 

b. Time 

c. OpenGL 

d. OpenDL 


Answer- Boost 


Que- Which header file is used to manipulate the vector algebra in c++? 

a. math 

b. cmath 

c. vmath 

d. dmath 


Answer- vmath 


Que- What type of reference should be used in vector arithmetic? 

a. dynamic 

b. const 

c. both dynamic & const 

d. static 


Answer- const 


Que- What will be the type of output of vector cross product? 

a. Scalar 

b. Vector 

c. Both Scalar & Vector 

d. Linear 


Answer- Vector 


Que- Which function is used to optimize the space in vector? 

a. at 

b. bool 

c. operator 

d. operand 


Answer- bool 


Que- What is the use of vector arithmetic in c++? 

a. Computer graphics 

b. Computer booting 

c. Both Computer graphics & Computer booting 

d. Computer Networks 


Answer- Computer graphics 


Que- Which header file is used to operate on numeric sequences? 

a. number 

b. numeric 

c. algorithm 

d. digit 


Answer- numeric 


Que- Which mathematics library is used for vector manipulation in c++? 

a. cli++ 

b. vec++ 

c. blitz++ 

d. stac+++ 


Answer- blitz++ 


Que- What is the use of accumulate function in a numeric library? 

a. Returns the number 

b. Returns the result of accumulating all the values in the range 

c. Returns the number & result 

d. Return the characters 


Answer- Returns the result of accumulating all the values in the range 


Que- How many parameters are available in partial_sum function in c++? 

a. 2 

b. 3 

c. 2 or 3 

d. 3 or 4 


Answer- 3 or 4 


Que- What is the default operation of adjacent_difference function in numeric library? 

a. Difference 

b. Addition 

c. Multiplication 

d. Subtraction 


Answer- Difference 


Que- Which header file is used to create the pseudo random generator? 

a. random 

b. cstdlib 

c. rand 

d. both random and cstdlib 


Answer- both random and cstdlib 


Que- Which is a constant defined in <cstdlib> header file? 

a. RAND_MAX 

b. Rand 

c. Srand 

d. Blitz 


Answer- RAND_MAX 


Que- How many parameters are available in srand function? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 1 


Que- Which operator is used to produce a certain number in a specific range? 

a. $ 

b. % 

c. modulo operator 

d. both % and modulo operator 


Answer- both % and modulo operator 


Que- Which can be used to create a random number without duplication? 

a. Character 

b. Time 

c. Both Character & Time 

d. Date 


Answer- Time 


Que- Which header file is required to use file I/O operations? 

a. <ifstream> 

b. <ostream> 

c. <fstream> 

d. <iostream> 


Answer- <fstream> 


Que- Which of the following is used to create an output stream? 

a. ofstream 

b. ifstream 

c. iostream 

d. fsstream 


Answer- ofstream 


Que- Which of the following is used to create a stream that performs both input and output operations? 

a. ofstream 

b. ifstream 

c. iostream 

d. fstream 


Answer- fstream 


Que- Which of the following is not used as a file opening mode? 

a. ios::trunc 

b. ios::binary 

c. ios::in 

d. ios::ate 


Answer- ios::trunc 


Que- By default, all the files in C++ are opened in _________ mode. 

a. Text 

b. Binary 

c. ISCII 

d. VTC 


Answer- Text 


Que- What is the use of ios::trunc mode? 

a. To open a file in input mode 

b. To open a file in output mode 

c. To truncate an existing file to half 

d. To truncate an existing file to zero 


Answer- To truncate an existing file to zero 


Que- Which of the following is the default mode of the opening using the ofstream class? 

a. ios::in 

b. ios::out 

c. ios::app 

d. ios::trunc 


Answer- ios::out 


Que- What is the return type open() method? 

a. int 

b. char 

c. bool 

d. float 


Answer- bool 


Que- Which of the following is not used to seek file pointer? 

a. ios::set 

b. ios::end 

c. ios::cur 

d. ios::beg 


Answer- ios::set 


Que- Which of the following is the default mode of the opening using the ifstream class? 

a. ios::in 

b. ios::out 

c. ios::app 

d. ios::trunc 


Answer- ios::in 


Que- Which function is used in C++ to get the current position of file pointer in a file? 

a. tell_p() 

b. get_pos() 

c. get_p() 

d. tell_pos() 


Answer- tell_p() 


Que- Which function is used to reposition the file pointer? 

a. moveg() 

b. seekg() 

c. changep() 

d. go_p() 


Answer- seekg() 


Que- Which of the following is used to move the file pointer to start of a file? 

a. ios::beg 

b. ios::start 

c. ios::cur 

d. ios::first 


Answer- ios::beg 


Que- What is lambda expression in C++? 

a. A technique of C++ that allows us to write inline functions without a name 

b. A technique of C++ that allows us to write overloaded functions 

c. A technique of C++ that allows us to write functions that are called more than once 

d. A technique of C++ that allows us to write functions without parameters 


Answer- A technique of C++ that allows us to write inline functions without a name 


Que- What is the syntax of defining lambda expression? 

a. [capture clause](parameters) -> return_type { body of the function } 

b. [parameters](capture clause) -> return_type { body of the function } 

c. [parameters:capture clause]() -> return_type { body of the function } 

d. [capture clause:parameters]() -> return_type { body of the function } 


Answer- [capture clause](parameters) -> return_type { body of the function } 


Que- What is the correct statement about lambda expression? 

a. The return type of lambda expression can be neglected in some cases 

b. The return type of lambda expression must be specified in all cases 

c. Lambda expression should be very large functions 

d. Lambda expression is also available in C 


Answer- The return type of lambda expression can be neglected in some cases 


Que- In how many ways we can capture the external variables in the lambda expression? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which of the following operator is used to capture all the external variable by reference? 

a. & 

b. = 

c. * 

d. && 


Answer- & 


Que- Which of the following operator is used to capture all the external variable by value? 

a. & 

b. = 

c. * 

d. && 


Answer- = 


Que- Which is the correct syntax of capturing a variable 'X' by reference and other variable 'Y' by value in lambda expression? 

a. [&X, Y] 

b. [X, &y] 

c. [X, Y] 

d. [&x, &Y] 


Answer- [&X, Y] 


Que- What are command line arguments? 

a. Arguments passed to main() function 

b. Arguments passed to any function 

c. Arguments passed to class functions 

d. Arguments passed to structure functions 


Answer- Arguments passed to main() function 


Que- To use command line arguments in C++, how many parameters are passed to the main function? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- What is the signature of math in function using command line arguments? 

a. int main(int argc, char const *argv[]); 

b. int main(int argc, char const **argv); 

c. int main(int argc, char **argv); 

d. all of the mentioned 


Answer- all of the mentioned 


Que- What does the first parameter of the main function represent? 

a. Number of command line arguments 

b. List of command line arguments 

c. Dictionary of command line arguments 

d. Stack of command line arguments 


Answer- Number of command line arguments 


Que- What does the second parameter of the main function represent? 

a. Number of command line arguments 

b. List of command line arguments 

c. Dictionary of command line arguments 

d. Stack of command line arguments 


Answer- List of command line arguments 


Que- Which of the following is correct about the first parameter of the main function? 

a. First argument is of int type 

b. Stores the count of command line arguments 

c. First argument is non-negative 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which of the following is correct about the second parameter of the main function? 

a. Second parameter is an array of character pointers 

b. First string of the list is the name of the program's output fle 

c. The string in the list are separated by space in the terminal 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which of the following gives the name of the program if the second parameter to the main function is char **argv? 

a. argv[3] 

b. argv[1] 

c. argv[0] 

d. argv[2] 


Answer- argv[0] 

Previous Post Next Post

Responsive Ad