C++ MCQ Questions and Answers: C++ is one of the most important and popular languages in computer programming. It can produce highly efficient codes that show high performance.
Due to their extreme importance, students need to practice C++ MCQ Questions and Answers to clear various exams.
Hence, in this article, we provide you with 20 C++ MCQ Questions and Answers. The Answers to the 20 C++ MCQ Questions and Answers are given at the end.
A list of C++ MCQ Questions and Answers are as follows
(a) Main Function Section
(b) Definition Section
(c) Linking Section
(d) Documentation Section
(a) -32,768 to 32,767
(b) -128 to 127
(c) -3276999 to 3276998
(d) 0 to 65535
(a) Keyword
(b) Pointer
(c) Constants
(d) Operators
(a) An integer value with base 10 is called a decimal integer
(b) Real constants are also known as floating-point constants
(c) An integer value with base 16 is called Hexa decimal integer
(d) Real Constants have only decimal parts and no fraction part
(a) A variable is an identifier
(b) Variables can be changed during the execution of the program
(c) Variable names are case sensitive
(d) Existing keywords, operators, separators, and constants values are allowed in variable declaration
(a) Variables which are defined inside a function are called Local Variables
(b) Variables which are defined outside of any function are Global Variables
(c) Variables declared with constant keywords are called constant variables
(d) Constant variables are only at Local Level.
(a) Preprocessor Commands
(b) Constant Variable
(c) main () Function
(d) Local Variable
(a) Pretest Loop
(b) Mid Test Loop
(c) Post Test Loop
(d) No Test Loop
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,f;
clrscr();
printf(“enter a value=”);
scanf(“%d”,&n);
i=0;
j=1;
printf(“%d\t%d”,i,j);
f=i+j;
while(f<=n)
{
printf(“\t %d”,f);
i=j;
j=f;
f=i+j;
}
getch();
}
Which of the following series will the above program return?
(a) Sum of n numbers
(b) Fibonacci Series
(c) Prime Numbers
(d) Sum of square of n numbers
(a) :
(b) .
(c) –
(d) +
See Also
Best Yuva Upanishad Books for GPSC/UPSC
(a) w – Opens or Creates a text file in Writing Mode
(b) r+ – Opens a text file in both Reading and Writing Mode
(c) ab – Opens a binary file in Append Mode
(d) w+ – Opens a text file in Append Mode
“#include<stdio.h>
void main()
{
FILE *fp;
char ch;
fp = fopen(“one.txt”, “w”);
printf(“Enter data…”);
while(ch = getchar()) != EOF)
{
putc(ch, fp);
}
fclose(fp);
fp = fopen(“one.txt”, “r”);
while( (ch = getc(fp)! = EOF)
printf(“%c”,ch);
// closing the file pointer
fclose(fp);
}
The Above program prints
(a) Contents entered in file one.txt
(b) Only integers from file one.txt
(c) Only float type from file one.txt
(d) None of the above
Data Type | Default value if not initialized | |
1 | Integer | 0 |
2 | Float | 0.00 |
3 | Char | NULL |
Which of the above is correctly matched
(a) Only 2
(b) 1 and 2
(c) 2 and 3
(d) 1,2 and 3
1) Function types
2) Pointer types
3) Integer types
4) Structure types
5) Union types
(a) 1,2, and 3
(b) 1, 3 and 5
(c) 1,2, 3 and 5
(d) 1,2,3 and 4
(a) It is mainly used to assign names to integral constants.
(b) If values are not assigned to enum, the compiler by default assigns values starting from 1
(c) The value assigned to enum names must be some integral constant
(d) All enum constants must be unique in their scope
Statement 1 – The malloc() function allocates memory and leaves the memory uninitialized.
Statement 2 – The calloc() function allocates memory and initializes all bits to one.
Choose the appropriate option below
(a) Statement 1 and Statement 2 are Correct
(b) Statement 1 is Correct but Statement 2 is Incorrect
(c) Statement 1 and Statement 2 are Incorrect
(d) Statement 1 is Incorrect but Statement 2 is Correct
Statement 1 – Operators like +, *, -, <=, >=, etc. work only on standard data types
Statement 2 – In C++ we can overload these operators to make them work even with user-defined data types.
(a) Statement 1 and Statement 2 are Correct
(b) Statement 1 is Correct but Statement 2 is Incorrect
(c) Statement 1 and Statement 2 are Incorrect
(d) Statement 1 is Incorrect but Statement 2 is Correct
Statement 1 – In Dynamic memory allocation, decision about how much space to allocate and the actual allocation both happen at the Compilation level
Statement 2 – When space is allocated for them, their address is returned and assigned to a pointer
(a) Statement 1 and Statement 2 are Correct
(b) Statement 1 is Correct but Statement 2 is Incorrect
(c) Statement 1 and Statement 2 are Incorrect
(d) Statement 1 is Incorrect but Statement 2 is Correct
Statement 1 – Static member functions can access only static data members
Statement 2 – Static data member has t obe declared inside the class but defined outside it
(a) Statement 1 and Statement 2 are Correct
(b) Statement 1 is Correct but Statement 2 is Incorrect
(c) Statement 1 and Statement 2 are Incorrect
(d) Statement 1 is Incorrect but Statement 2 is Correct
Statement 1 – C++ – Does Early Binding whenever possible and does Late Binding when Early Binding is not possible
Statement 2 – For Late Binding the function being called should be present in the base class as well as derived class
(a) Statement 1 and Statement 2 are Correct
(b) Statement 1 is Correct but Statement 2 is Incorrect
(c) Statement 1 and Statement 2 are Incorrect
(d) Statement 1 is Incorrect but Statement 2 is Correct
So these were the 20 C++ MCQ Questions and Answers
The answers of C++ MCQ Questions and Answers are as follows
1 | c |
2 | c |
3 | b |
4 | d |
5 | d |
6 | d |
7 | a |
8 | a |
9 | b |
10 | b |
11 | d |
12 | a |
13 | d |
14 | c |
15 | b |
16 | b |
17 | a |
18 | d |
19 | a |
20 | a |
So these were the Answers to C++ MCQ Questions and Answers
Thank you for reading C++ MCQ Questions and Answers
Share these 20 C++ MCQ Questions and Answers with your friends
During the worldwide fall of Communism, beginning in the 1980s, the West was gripped by…
Edward Hallett Carr is perhaps the greatest and most authentic authority when it comes to…
“The Army is the nation and the nation is with the Army”, COAS General Ashfaq…
Few scholarly works have modest beginnings but have become one of the most renowned seminal…
Few people in the USSR saw the end of the Cold War as a setback…
In 1921, Vladimir Lenin initiated a new economic agenda for the Soviet Union, which had…