Professional Documents
Culture Documents
C_ C++ by mahad
C_ C++ by mahad
C_ C++ by mahad
**Answer: B) variableName123**
**Answer: B) override**
**Answer: A) Hello**
2. Which loop in C++ executes at least once?
- A) for loop
- B) while loop
- C) do-while loop
- D) switch loop
5. Which access specifier in C++ allows class members to be accessed from outside the class?
- A) private
- B) protected
- C) public
- D) friend
**Answer: C) public**
**Answer: C) The value at the memory address pointed to by the pointer is accessed**
**Answer: B) `_myVariable`**
b) What is the data type of the variable storing whole numbers in C++?
- A) `int`
- B) `char`
- C) `float`
- D) `bool`
**Answer: A) `int`**
**Answer: C) `13`**
**Answer: A) `&&`**
3. **Control Structures**
**Answer: B) `break`**
a) What is the return type of a function that doesn't return any value in C++?
- A) `void`
- B) `null`
- C) `int`
- D) `none`
**Answer: A) `void`**
b) Which of the following is NOT a valid way to pass arguments to a function in C++?
- A) Pass by reference
- B) Pass by value
- C) Pass by pointer
- D) Pass by array
This covers the first four points of the outline. If you'd like more questions or have any specific
areas you'd like to focus on, please let me know!
Certainly! Here are additional multiple-choice questions for the remaining outlined points.
**Answer: B) `class`**
b) What is the access specifier that restricts access to class members within the same class
in C++?
- A) `public`
- B) `private`
- C) `protected`
- D) `access`
**Answer: B) `private`**
**Answer: D) `:`**
8. **Memory Management**
a) What happens when a memory leak occurs in C++?
- A) Excessive memory is deallocated
- B) Memory is allocated but not deallocated, causing a loss of available memory
- C) Memory is allocated and deallocated properly
- D) Memory allocation fails due to insufficient resources
**Answer: B) Memory is allocated but not deallocated, causing a loss of available memory**
**Answer: A) `delete`**
This concludes the 10 MCQs for each of the outlined points. If you'd like more questions or have
specific areas to focus on, feel free to ask!
Absolutely, here are additional multiple-choice questions for the remaining topics.
a) Which container in STL provides constant time insertion and deletion at the beginning and
end?
- A) `vector`
- B) `list`
- C) `deque`
- D) `map`
**Answer: C) `deque`**
**Answer: A) `sort()`**
**Answer: C) `<fstream>`**
**Answer: B) `ofstream`**
a) What is the purpose of the 'try', 'catch', and 'throw' keywords in C++?
- A) Terminating the program
- B) Handling exceptional situations and errors
- C) Controlling loops
- D) Defining class constructors
**Answer: B) `catch`**
This concludes the additional set of multiple-choice questions for the outlined topics. If you need
more or have any specific areas in mind, feel free to ask!
Absolutely, here are more multiple-choice questions for the outlined topics.
b) Which type of template allows for different data types to be used in functions or classes?
- A) Function templates
- B) Class templates
- C) Template specialization
- D) Member templates
I hope these additional questions further enhance your understanding of the outlined topics in
C++. If you need more or have specific areas to focus on, feel free to ask!
Certainly! Here are some multiple-choice questions (MCQs) about the C programming language
along with their respective answers:
**Answer: C) `int`**
**Answer: D) 1 byte**
**Answer: B) `2`**
**Answer: A) `*`**
3. **Control Structures**
**Answer: B) `break`**
**Answer: D) `params`**
This set covers some basic aspects of the C programming language. If you'd like more
questions or specific topics, feel free to ask!
Certainly! Here are more multiple-choice questions on various aspects of the C programming
language:
1. **Arrays**
**Answer: A) `numbers[2]`**
2. **Pointers**
**Answer: B) `10`**
3. **File Handling**
**Answer: C) `<stdio.h>`**
4. **Input/Output**
**Answer: C) `printf()`**
Feel free to ask for more questions or if there's a specific area you'd like to focus on!
Of course! Here are additional multiple-choice questions covering different areas of the C
programming language:
1. **Structures**
**Answer: B) `person.age`**
**Answer: B) `struct`**
2. **Unions**
**Answer: C) Structures store all members simultaneously, unions share the same memory**
3. **Memory Allocation**
**Answer: A) `malloc()`**
4. **Preprocessor Directives**
**Answer: A) `#`**
Feel free to ask for more questions or any specific topic you'd like to focus on!
Absolutely! Here are additional multiple-choice questions covering various aspects of C
programming:
1. **Function Pointers**
2. **Recursion**
3. **Bitwise Operators**
4. **Enumerations**
1. **Strings in C**
**Answer: B) `strlen()`**
**Answer: A) `<string.h>`**
3. **Memory Handling**
**Answer: C) `memcpy()`**
4. **Dynamic Allocation**
**Answer: A) `free()`**
Feel free to ask for more questions or if there's a particular topic you'd like to focus on!
Certainly! Here are additional multiple-choice questions focusing on various concepts in C
programming:
**Answer: C) `fopen()`**
2. **Input/Output Operations**
b) How do you print a floating-point number with two decimal places using `printf()` in C?
- A) `%f.2`
- B) `%.2f`
- C) `%2f`
- D) `%.f2`
**Answer: B) `%.2f`**
3. **Command-Line Arguments**
a) What is the significance of `argc` and `argv` in C?
- A) `argc` stores the number of arguments and `argv` stores the argument values
- B) `argc` stores the argument values and `argv` stores the number of arguments
- C) Both `argc` and `argv` store the number of arguments
- D) Both `argc` and `argv` store the argument values
**Answer: A) `argc` stores the number of arguments and `argv` stores the argument values**
4. **Error Handling**
b) Which library contains the `errno` variable used for error handling in C?
- A) `<stdio.h>`
- B) `<stdlib.h>`
- C) `<errno.h>`
- D) `<error.h>`
**Answer: C) `<errno.h>`**
1. **Bitwise Operations**
**Answer: B) `14`**
2. **Macros**
3. **Pointers**
4. **Memory Allocation**
**Answer: B) `free()`**
**Answer: C) `int`**
**Answer: A) `&&`**
**Answer: A) `1`**
3. **Control Structures**
**Answer: C) `break`**
4. **Functions**
a) What is the return type of a function that doesn't return any value in C++?
- A) `void`
- B) `null`
- C) `none`
- D) `int`
**Answer: A) `void`**
These questions cover fundamental aspects of C++. Let me know if you'd like more questions or
have specific topics in mind!
Certainly! Here are more multiple-choice questions covering various concepts in C++:
a) What is the access specifier used to make class members accessible within the same
class and derived classes in C++?
- A) `public`
- B) `private`
- C) `protected`
- D) `access`
**Answer: C) `protected`**
**Answer: D) `:`**
3. **Templates**
**Answer: A) `vector`**
Feel free to ask for more questions or specific topics you want to cover!
Absolutely! Here are more multiple-choice questions covering additional aspects of C++
programming:
1. **Exception Handling**
a) What is the purpose of the `try`, `catch`, and `throw` keywords in C++?
- A) Managing memory allocation
- B) Handling exceptional situations and errors
- C) Defining class inheritance
- D) Initializing objects
b) Which block is executed whether an exception is thrown or not in a try-catch block in C++?
- A) `try`
- B) `catch`
- C) `finally`
- D) `throw`
**Answer: C) `finally`**
**Answer: A) `write()`**
3. **Memory Management**
**Answer: B) `new`**
**Answer: A) `delete`**
4. **Smart Pointers**
a) Which smart pointer type in C++ automatically deletes the associated object when it's no
longer needed?
- A) `weak_ptr`
- B) `shared_ptr`
- C) `unique_ptr`
- D) `auto_ptr`
**Answer: C) `unique_ptr`**
If you need more questions or have specific areas to focus on, feel free to ask!
b) Which algorithm from `<algorithm>` header in C++ STL is used for sorting elements?
- A) `sort()`
- B) `search()`
- C) `copy()`
- D) `transform()`
**Answer: A) `sort()`**
2. **Advanced Concepts**
a) What is the purpose of the `virtual` keyword in C++ for member functions?
- A) To make functions accessible from anywhere in the program
- B) To define a function in a derived class
- C) To enable polymorphic behavior and late binding
- D) To restrict access to functions
3. **Lambda Expressions**
b) Which capture mode in a lambda expression captures all referenced variables by value?
- A) `[=]`
- B) `[&]`
- C) `[&=]`
- D) `[=, &]`
**Answer: A) `[=]`**
4. **Move Semantics**
**Answer: C) `move`**
Feel free to ask for more questions or if there's a specific topic you'd like to focus on!
Absolutely! Here are more multiple-choice questions covering various aspects of C++
programming:
1. **Function Templates**
**Answer: B) To create generic functions that work with different data types**
2. **Class Templates**
3. **STL Algorithms**
a) Which algorithm from the `<algorithm>` header in C++ STL is used for finding the
maximum element in a range?
- A) `max_element()`
- B) `find()`
- C) `max()`
- D) `search()`
**Answer: A) `max_element()`**
4. **Smart Pointers**
b) Which smart pointer in C++ allows sharing ownership of the managed object?
- A) `std::unique_ptr`
- B) `std::weak_ptr`
- C) `std::auto_ptr`
- D) `std::shared_ptr`
**Answer: D) `std::shared_ptr`**
Feel free to ask for more questions or specify any topic you'd like to focus on!