UPSC

C++ MCQ Questions and Answers

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.

C++ MCQ Questions and Answers

A list of C++ MCQ Questions and Answers are as follows

  1. Which of the following section tells the compiler to link certain occurrences of keywords or functions in a program to header files specified in this section

                   (a)    Main Function Section

                   (b)    Definition Section

                   (c)    Linking Section

                   (d)    Documentation Section

  1. Which of the following is the correct range of “Floating Point Data Type”?

                    (a)   -32,768 to 32,767

                    (b)   -128 to 127

                    (c)   -3276999 to 3276998

                    (d)    0 to 65535

  1. Which of the following is not a C Token?

                     (a)  Keyword

                     (b)  Pointer

                     (c)  Constants

                     (d)  Operators

  1. Which of the following Statements is incorrect?

                     (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

  1. Which of the following statement is incorrect about Variables?

                     (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

  1. Which of the following is incorrect?

                       (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.

  1. Which of the following are used to place library information in a program?

                       (a)    Preprocessor Commands

                       (b)    Constant Variable

                       (c)    main () Function

                       (d)    Local Variable

  1. In which of the following we test to see whether or not to continue before executing the body of the loop?

                        (a)   Pretest Loop

                        (b)   Mid Test Loop

                        (c)   Post Test Loop

                        (d)   No Test Loop

  1. Consider the Program below

#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

  1. To access any member of a union, which of the following operator is used?

                             (a)  :

                             (b)  .

                             (c)  –

                             (d)  +

See Also

Best Yuva Upanishad Books for GPSC/UPSC

  1. Which of the following is not matched correctly?

                             (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

  1. Consider the following Program

“#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 TypeDefault value if not initialized
1Integer0
2Float0.00
3CharNULL

Which of the above is correctly matched

                             (a)  Only 2

                             (b)  1 and 2

                             (c)   2 and 3

                             (d)  1,2 and 3

  1. Which of the following are derived types in C:

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

  1. Which of the following is false regarding the Enumerated Data Type?

     (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

  1. Consider the two statements below

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

  1. Consider the following Statements

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

  1. Consider the following Statements

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

  1. Consider the following Statements

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

  1. Consider the following Statements

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

Answers of C++ MCQ Questions and Answers

The answers of C++ MCQ Questions and Answers are as follows

1c
2c
3b
4d
5d
6d
7a
8a
9b
10b
11d
12a
13d
14c
15b
16b
17a
18d
19a
20a

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

Gautam Kukreja

Recent Posts

Review: The Failure of Political Islam by Olivier Roy

During the worldwide fall of Communism, beginning in the 1980s, the West was gripped by…

2 months ago

Book Review: E.H. Carr’s A History of Soviet Russia: Volume 1: The Bolshevik Revolution

Edward Hallett Carr is perhaps the greatest and most authentic authority when it comes to…

2 months ago

Political Economy of Pakistan’s Military

“The Army is the nation and the nation is with the Army”, COAS General Ashfaq…

2 months ago

Book Review– The Great Transformation by Karl Polanyi

Few scholarly works have modest beginnings but have become one of the most renowned seminal…

2 months ago

The Disintegration of the USSR: the Factors

Few people in the USSR saw the end of the Cold War as a setback…

2 months ago

Soviet Economy after the October Revolution

In 1921, Vladimir Lenin initiated a new economic agenda for the Soviet Union, which had…

3 months ago