๐•Š๐•š๐•ฃ๐”น๐•š๐•œ๐•ฃ๐•’๐•ž๐•Š๐•ฆ๐•ฅ๐•ฃ๐•’๐••๐•™๐•’๐•ฃ : World Record Holder & Best Teacher Award 2023

GrandMaster Bikram Sutradhar: 5-Time World Record Holder & Best Teacher, Expert in NEET, IIT JEE, CBSE, ICSE ,TBSE We provide Education GK & International News , University , Institutions , Job, Phd Solutions

C and C++ Programming Multiple Choice Questions

C Programming and C++ Programming with Fundamentals set by Bikram Sutradhar

  1. What is the correct syntax to declare an array of integers with 10 elements in C?
    a) int array[10];
    b) int array(10);
    c) array int[10];
    d) int[10] array;
    Answer: a) int array[10];
  2. Which of the following is the correct way to read a string from user input in C?
    a) scanf(“%s”, str);
    b) getline(str);
    c) input(str);
    d) read(str);
    Answer: a) scanf(“%s”, str);
  3. What will the following code print? int a=3,b=5;
    printf(“%d”, a > b ? a : b); a) 3
    b) 5
    c) 0
    d) 1
    Answer: b) 5
  4. Which function is used to free dynamically allocated memory in C?
    a) freeMemory();
    b) release();
    c) free();
    d) deallocate();
    Answer: c) free();
  5. What does the following code do? int x = 10;
    int *ptr = &x;
    *ptr = 20; a) Changes x to 10
    b) Changes ptr to 20
    c) Changes x to 20
    d) Causes a segmentation fault
    Answer: c) Changes x to 20

Section 2: C++ Programming

  1. In C++, what keyword is used to inherit a class?
    a) extends
    b) inherits
    c) class
    d) :
    Answer: d) :
  2. output of the C++ code? int arr[] = {1, 2, 3};
    cout << arr[1]; a) 1
    b) 2
    c) 3
    d) Compilation error
    Answer: b) 2
  3. Which of the following correctly defines a destructor in C++?
    a) ~ClassName();
    b) ClassName();
    c) destroy ClassName;
    d) ClassName::~();
    Answer: a) ~ClassName();
  4. What is the purpose of the const keyword in C++?
    a) To declare a constant variable
    b) To define a class
    c) To create a pointer
    d) To overload operators
    Answer: a) To declare a constant variable
  5. Which of the following is a feature of Object-Oriented Programming in C++?
    a) Inheritance
    b) Encapsulation
    c) Polymorphism
    d) All of the above
    Answer: d) All of the above

Section 3: General Concepts

  1. Which of the following directives is used to include standard libraries in C/C++?
    a) #library
    b) #include
    c) #define
    d) #import
    Answer: b) #include
  2. What is the primary purpose of the main() function?
    a) To define classes
    b) To execute the program
    c) To include libraries
    d) To declare variables
    Answer: b) To execute the program
  3. In C/C++, which loop is guaranteed to execute at least once?
    a) for loop
    b) while loop
    c) do-while loop
    d) None of the above
    Answer: c) do-while loop
  4. Which operator is used for pointer dereferencing in C/C++?
    a) &
    b) *
    c) ->
    d) .
    Answer: b) *
  5. output of the code?

for (int i = 1; i <= 3; i++) {
cout << i;
}
a) 012
b) 123
c) 1234
d) 234
Answer: b) 123

Bikram Sutradhar Notes

Mastering C, C++, Java, and HTML: Your Ultimate Programming Questions Answered

C Programming and C++ Programming Mcq Question answer

Tripura board of secondary education Class 12 Education Important &  Model Question Solution 

Tripura board of secondary education Class 12 economics Important &  Model Question Solution

Comprehensive Guide to the Digestive System: Selina Class 9 Biology Solutions Hindi & English

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!