Solved MCQs Of C++ With Answers for Online Test Preparation
Are you looking for a comprehensive resource to help you test your knowledge of C++? If so, you have come to the right place! Here we provide a detailed collection of ‘Solved MCQs Of C++ With Answers‘ that are designed to help you assess your understanding of the language and give you the confidence to excel in competitive exams.
These MCQs cover a range of topics from the fundamentals of C++ to more advanced concepts. The answers provided with each question also act as a great source of reference to learn more about the language. So, let‘s get started and make sure you are fully equipped to tackle any C++ MCQs that come your way!
Basics of C++ MCQs Questions with Answers
In this chapter of Solved MCQs of C++ with answers you will find fundamental MCQs of C++.
1: C++ programing language was developed by:
- a) Master Marten Richard
- b) Dennis Ritche
- c) Bjarne Strotrup
- d) None of above
c) Bjarne Strotrup
2: The file extension of a C++ program is:
- a) .cpp
- b) .c
- c) .obj
- d) .exe
a) .cpp
3: Which of the following is/are the main parts of a C++ program?
- a) Preprocessor Directives
- b) The main ( ) Function
- c) C++ Statments
- d) All of above
d) All of above
4: The “main ( )” function indicates the __________ of a C++ program.
- a) beginning
- b) ending
- c) input
- d) output
a) beginning
5: A________ is a quantity whose value may change during execution of the program.
- a) constant
- b) data type
- c) variable
- d) character
c) variable
6: The storage capacity of unsigned int is:
- a) 1 bit
- b) 2 bytes
- c) 4 bytes
- d) 8 bytes
b) 2 bytes
7: the data type which is used to store characters is:
- a) float
- b) double
- c) long double
- d) char
d) char
8: Numeric values that have an integer, as well as a decimal part, is known as:
- a) Integer constant
- b) Floating-point constant
- c) Character constant
- d) String constant
b) Floating-point constant
9: Which of the following is an example of a string constant?
- a) 5560
- b) abc
- c) T-20
- d) 65.8
c) T-20
10: A preprocessor directive which is used to define a constant quantity is:
- a) #define
- b) #include
- c) Both
- d) None
a)#define
Basic Input and Output in C++ MCQs
In this section of solved MCQs of C++ with answers, you find basic input and output, as well as some conditional statements MCQs in C++.
11: COUT stands for:
- a) Common output
- b) Console output
- c) Computer output
- d) Cancel output
b) Console output
12: The flow of data from one location to another is called________.
- a) output
- b) input
- c) stream
- d) execution
c) stream
13: In C++ the Clrscr( ); is used to:
- a) set the width of the screen
- b) provide output on the screen
- c) cancel output on the screen
- d) clear the screen
d) clear the screen
14: Most commonly used C++ manipulator used to set the width of output on the output device is:
- a) endl
- b) setw
- c) clsrscr
- d) cin
b) setw
15: The ________ operator is used as a modules arithmetic operator.
- a) /
- b) *
- c) %
- d) +
c) %
16: The __________ escape sequence is used to insert a new line.
- a) endl;
- b) \n
- c) \t
- d) \a
b) \n
17: The ______ is used to give comments in C++ program.
- a) #
- b) //
- c) ;
- d) :
b)//
18: Which of the given function indicates the start of a C++ program?
- a) main ( )
- b) clrscr( )
- c) get ( )
- d) cin
a) main ( )
19: A float type variable occupies __________ bytes in memory.
- a) 4
- b) 8
- c) 16
- d) 32
a) 4
20: Which of the following is a valid variable name in C++?
- a) include
- b) main
- c) name
- d) h rent
c) name
Loop MCQs with Answers
In this unit of solved MCQs of C++ with answers we have covered important MCQs of loops in C++.
21: What is the purpose of a loop in C++?
- a) To repeat a block of code multiple times
- b) To control the flow of a program
- c) To store data
- d) None of the above
a) To repeat a block of code multiple times
22: The difference between a for loop and a while loop in C++?
- a) A for loop is used for a specific number of iterations, while a while loop is used for an indefinite number of iterations
- b) A while loop is used for a specific number of iterations, while a for loop is used for an indefinite number of iterations
- c) Both are the same thing
- d) None of the above
a) Correct Answer
23: The purpose of the break statement in C++?
- a) To exit a loop early
- b) To continue to the next iteration of a loop
- c) To start a new loop
- d) None of the above
a) To exit a loop early
24: What is the purpose of the continue statement in C++?
- a) To exit a loop early
- b) To continue to the next iteration of a loop
- c) To start a new loop
- d) None of the above
: b) To continue to the next iteration of a loop
25: The primary purpose of the do-while loop is?
- a) To repeat a block of code multiple times, and ensure that the code runs at least once
- b) To control the flow of a program
- c) To store data
- d) None of the above
a) Correct Answer
26: Nested loop in C++ is used for:
- a) To repeat a block of code multiple times within another loop
- b) To control the flow of a program
- c) To store data
- d) None of the above
a) Correct Answer
27: How can we control the number of iterations in a for loop in C++?
- a) By using the break statement
- b) By using the continue statement
- c) By providing a counter variable and a condition for the loop
- d) None of the above
c) Correct Answer
Array MCQs with Answers
An array is one of the most important topics in C++. Therefore we have also included important MCQs of Array in solved MCQs of C++ with answers.
28: An array is a collection of elements of the ___________, stored in contiguous memory locations.
- a) same data type
- b) different data type
- c) smallest values
- d) largest values
a) same data type
29: An array can be declared by specifying the data type, followed by the array name and the size of the array within ________.
- a) small brackets
- b) square brackets
- c) curly brackets
- d) parenthesis
b) square brackets
30: Which of the following is the correct initialization of an Array in C++?
- a) int myArray[5] = {1,2,3,4,5};
- b) my[5]={1,2,3,4,5};
- c) int myArray[]={1,2,3,4,5}
- d) int myArray[5]=(1,2,3,4,5)
a) int myArray[5] = {1,2,3,4,5};
31: Elements in an array can be accessed by specifying the ___________within square brackets.
- a) array name
- b) index of the element
- c) both a and b
- d) none of above
c) both a and b
32: myArray[2] would access the _________ element of the array.
- a) first
- b) second
- c) third
- d) fourth
c) third
33: The size of an array in C++ is the number of ________ that the array can hold.
- a) characters
- b) variables
- c) constants
- d) elements
d) elements
34:
for(int i = 0; i < 5; i++)
{
cout << myArray[i] << endl;
}
In the above C++ program the loop variable represents the index of the_________ element
- a) previous
- b) current
- c) last
- d) fifth
b) current
35: The length of an array can be found by using the _________ and dividing it by the size of the data type of the array.
- a) clrscr( ) function
- b) sizeof( ) function
- c) main ( ) function
- d) None of these
b) sizeof ( ) function
Structure MCQs with Answers
In this chapter you will find important MCQs of Structure in C++.
36: The keyword used to define a structure in C++ is:
- a) struct
- b) class
- c) define
- d) variable
a) struct
37: How do you access the members of a structure in C++?
- a) Using -> operator
- b) Using :: operator
- c) Using . operator
- d) Using & operator
c) Using . operator
38: What is the difference between a structure and a class in C++?
- a) Structures have public members by default, classes have private members by default
- b) Structures cannot have functions, classes can
- c) Structures can only be used for primitive data types, classes can be used for any data type
- d) There is no difference between the two
a) Correct Answer
39: How do you initialize the members of a structure when creating an instance?
- a) Using the keyword “new”
- b) Using the keyword “struct”
- c) Using the curly braces {}
- d) Using the keyword “initialize”
c) Using the curly braces {}
Function MCQs with Answers
In this unit of solved MCQs of C++ with answers, you will find solved MCQs of functions with answers.
40: What is the purpose of a function in C++?
- a) To group a set of instructions that perform a specific task
- b) To declare variables
- c) To control the flow of a program
- d) To print output
a) Correct Answer
41: How are functions defined in C++?
- a) Using the keyword “function”
- b) Using the keyword “def”
- c) Using the keyword “void”
- d) Using the keyword “int”
d) Using the keyword “int”
42: What is the syntax for defining a function in C++?
- a) function function_name();
- b) def function_name();
- c) int function_name();
- d) void function_name();
c) int function_name();
43:The purpose of a function return type in C++?
- a) To specify the data type of the value returned by the function
- b) To specify the number of arguments passed to the function
- c) To specify the scope of the function
- d) To specify the memory allocation for the function
a) Correct Option
44: The purpose of function parameters in C++?
- a) To specify the data type of the value returned by the function
- b) To specify the number of arguments passed to the function
- c) To specify the scope of the function
- d) To pass values to the function when it is called
d) Correct Answer
45: What is the keyword used to return a value from a function in C++?
- a) exit
- b) return
- c) end
- d) finish
b) return
Pointer MCQs with Answer
46 : A pointer in C++ is used to_________.
- a) To store the name of a variable
- b) To store the value of a variable
- c) To store the memory address of a variable
- d) None of the above
c) Correct Answer
47: How is a pointer variable declared in C++?
- a) ptr *int;
- b) int *ptr;
- c) *ptr int;
- d) int ptr;
b) int *ptr;
48: What is the difference between a variable and a pointer in C++?
- a) A variable stores a value, while a pointer stores the memory address of a variable
- b) A variable stores the memory address of a variable, while a pointer stores a value
- c) Both are the same thing
- d) None of the above
a) Correct Answer
49: The primary purpose of the address-of operator (&) in C++?
- a) It is used to assign a value to a pointer
- b) It is used to access the value stored at the memory address stored by a pointer
- c) It is used to get the memory address of a variable
- d) None of the above
c) Correct Answer
50: The difference between a regular variable and a pointer variable?
- a) A regular variable stores a value, while a pointer variable stores the memory address of a variable
- b) A regular variable stores the memory address of a variable, while a pointer variable stores a value
- c) Both are the same thing
- d) None of the above
a) Correct Answer
Conclusion:
This article has provided a comprehensive overview of the solved MCQs of C++ with answers. This article has provided useful information for those looking for more information on C++ and its related topics. With this information, anyone should be able to solve the MCQs and gain a better understanding of C++.