C/C++ Programming

1. What is the meaning of "void" in C/C++?

A. It is a data type

B. It is a keyword for functions that return no value

C. It is a pointer type

D. It is a loop statement

     B. It is a keyword for functions that return no value

2. Which operator is used to allocate memory dynamically in C++?

A. new

B. delete

C. malloc

D. free

     A. new

3. What is the difference between "==" and "=" in C/C++?

A. “==” is used for assignment, “=” is used for comparison

B. “==” is used for comparison, “=” is used for assignment

C. “==” is used for logical AND, “=” is used for logical OR

D. “==” is used for bitwise AND, “=” is used for bitwise OR

     B. “==” is used for comparison, “=” is used for assignment

4. What is the purpose of the "const" keyword in C/C++?

A. To declare a constant variable

B. To declare a pointer

C. To declare a reference

D. To declare a class

     A. To declare a constant variable

5. Which loop statement is used to execute a block of code repeatedly for a specified number of iterations?

A. while

B. for

C. do-while

D. switch

     B. for

6. What is the purpose of the "this" pointer in C++?

A. To point to the current object

B. To point to the base class

C. To point to the derived class

D. To point to the global variables

     A. To point to the current object

7. Which function is used to terminate a program in C/C++?

A. exit()

B. return

C. break

D. continue

     A. exit()

8. What is the difference between "struct" and "class" in C++?

A. “struct” is used for built-in types, “class” is used for user-defined types

B. “struct” is used for user-defined types, “class” is used for built-in types

C. “struct” is used for public members, “class” is used for private members

D. “struct” is used for private members, “class” is used for public members

     C. “struct” is used for public members, “class” is used for private members

9. Which operator is used to perform bitwise AND operation in C/C++?

A. &

B. |

C. ^

D. ~

     A. &

10. What is the purpose of the "virtual" keyword in C++?

A. To declare a virtual function

B. To declare a pure virtual function

C. To declare an abstract class

D. To declare a friend function

     A. To declare a virtual function

11. What is the purpose of the "static" keyword in C/C++?

A. To declare a static variable

B. To declare a static function

C. To declare a static class

D. To declare a static namespace

     A. To declare a static variable

12. Which function is used to convert a string to an integer in C/C++?

A. atoi()

B. itoa()

C. strtol()

D. strtoul()

     A. atoi()

13. What is the difference between "pass by value" and "pass by reference" in C/C++?

A. “pass by value” passes a copy of the variable, “pass by reference” passes the original variable

B. “pass by value” passes the original variable, “pass by reference” passes a copy of the variable

C. “pass by value” is used for built-in types, “pass by reference” is used for user-defined types

D. “pass by value” is used for user-defined types, “pass by reference” is used for built-in types

     A. “pass by value” passes a copy of the variable, “pass by reference” passes the original variable

14. Which function is used to print output to the screen in C?

A. printf()

B. scanf()

C. cout

D. cin

     A. printf()

15. What is the purpose of the "typedef" keyword in C/C++?

A. To declare a new data type

B. To declare a new function

C. To declare a new class

D. To declare a new namespace

     A. To declare a new data type

Scroll to Top