C Plus Plus Programming Quiz For Beginners

Reviewed by Samy Boulos
Samy Boulos, MSc (Computer Science) |
Data Engineer
Review Board Member
Samy Boulos is an experienced Technology Consultant with a diverse 25-year career encompassing software development, data migration, integration, technical support, and cloud computing. He leverages his technical expertise and strategic mindset to solve complex IT challenges, delivering efficient and innovative solutions to clients.
, MSc (Computer Science)
Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Andreeahrab
A
Andreeahrab
Community Contributor
Quizzes Created: 1 | Total Attempts: 13,792
Questions: 38 | Attempts: 13,798

SettingsSettingsSettings
C Plus Plus Programming Quiz For Beginners - Quiz


C++ is one of the common programming languages that most programmers are expected to have a good understanding of. Here is a C Plus Plus Programming Quiz For Beginners. Try this quiz and see if you can answer all the questions correctly or not. As you continue your journey with C++, it is important to see if you already understand the basics and this quiz will help you do just that. Give it a shot and be a step closer to being perfect when it comes to this language.


Questions and Answers
  • 1. 

    The notation of logical NOT operator in a C++ program is

    • A.

      :

    • B.

      ;

    • C.

      None of the Above

    • D.

      !

    Correct Answer
    D. !
    Explanation
    The correct answer is "!". In C++, the "!" symbol is used as the logical NOT operator. It is a unary operator that negates the truth value of its operand.

    Rate this question:

  • 2. 

    For the class exforsys defined as below: class exforsys { }; int main() { exforsys a; } Which of the following is TRUE?

    • A.

      No default constructor is provided by the compiler

    • B.

      The compiler provides the default constructor

    • C.

      The compiler generates error

    • D.

      None of the Above

    Correct Answer
    B. The compiler provides the default constructor
    Explanation
    The given code defines a class called exforsys and creates an object of this class named 'a' in the main function. Since no constructor is explicitly defined in the class, the compiler automatically provides a default constructor. Therefore, the correct answer is "The compiler provides the default constructor."

    Rate this question:

  • 3. 

    The notation of ternary operator is

    • A.

      &

    • B.

      ?:

    • C.

      ~

    • D.

      %

    Correct Answer
    B. ?:
    Explanation
    The notation of the ternary operator is "?:". This operator is a shorthand way of writing an if-else statement. It takes three operands - a condition, a value to be returned if the condition is true, and a value to be returned if the condition is false. The operator evaluates the condition, and if it is true, it returns the first value; otherwise, it returns the second value.

    Rate this question:

  • 4. 

    When the object of the first class is instantiated then which of the following is called?

    • A.

      Destructor

    • B.

      Constructor

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    B. Constructor
    Explanation
    When the object of the first class is instantiated, the constructor is called. The constructor is a special member function of a class that is automatically called when an object of that class is created. It is used to initialize the object's data members and perform any necessary setup operations. In this case, since the object of the first class is being created, the constructor of that class will be called.

    Rate this question:

  • 5. 

    Which of the following denotes the C++ looping statement?

    • A.

      Do-while

    • B.

      For

    • C.

      Both A and B

    Correct Answer
    C. Both A and B
    Explanation
    Both the do-while and for statements are looping statements in C++. The do-while statement executes a block of code at least once, and then repeatedly executes it as long as a certain condition is true. The for statement is used to execute a block of code repeatedly for a fixed number of times. Therefore, both options A (do-while) and B (for) are correct answers for this question.

    Rate this question:

  • 6. 

    Which of the following can be used to initialize a newly declared variable from an existing variable?

    • A.

      Virtual Function

    • B.

      Namespaces

    • C.

      Copy constructor

    • D.

      None of the Above

    Correct Answer
    C. Copy constructor
    Explanation
    A copy constructor can be used to initialize a newly declared variable from an existing variable. This constructor creates a new object by copying the values of another object of the same class. It is used when we want to create a new object that is a copy of an existing object. By using a copy constructor, we can ensure that the new object has the same values as the existing object, avoiding any potential issues with shallow copying or pointer manipulation.

    Rate this question:

  • 7. 

    A template can be instantiated by

    • A.

      Explicit Instantiation

    • B.

      Implicit instantiation

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    C. Both A and B
    Explanation
    A template can be instantiated by both explicit instantiation and implicit instantiation. Explicit instantiation occurs when the template is explicitly instantiated by the programmer using the template arguments. Implicit instantiation, on the other hand, happens automatically when the template is used with specific arguments in the code. Therefore, both A (explicit instantiation) and B (implicit instantiation) are valid ways to instantiate a template.

    Rate this question:

  • 8. 

    The minimum number of times a do loop would definitely get executed is: 

    • A.

      0

    • B.

      1

    • C.

      Infinity

    • D.

      Could not be predicted

    Correct Answer
    B. 1
    Explanation
    A do loop will definitely get executed at least once because the condition for exiting the loop is checked at the end of each iteration. Therefore, even if the condition is initially false, the loop will still execute once before checking the condition again.

    Rate this question:

  • 9. 

    Strict parameter type checking is followed by which of these?

    • A.

      Inline

    • B.

      Macros

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    A. Inline
    Explanation
    Inline is the correct answer because strict parameter type checking is followed by inline functions. Inline functions are a way to optimize code execution by inserting the function's code directly into the calling code, eliminating the overhead of function calls. Since the code is inserted directly, it allows for strict type checking of the parameters at compile time, ensuring that the correct types are used. Macros, on the other hand, are not subject to strict type checking as they are expanded by the preprocessor before compilation.

    Rate this question:

  • 10. 

    The variables that can be used only within the function in which it is declared is called as

    • A.

      Global Variables

    • B.

      Local Variables

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    B. Local Variables
    Explanation
    Local variables are variables that are declared within a specific function and can only be accessed and used within that function. They have a limited scope and are not accessible outside of the function. Global variables, on the other hand, can be accessed and used from any part of the program. Therefore, the correct answer is local variables.

    Rate this question:

  • 11. 

    How many values can be returned by a C++ function?

    • A.

      1

    • B.

      Infinity

    • C.

      0

    • D.

      None of the Above

    Correct Answer
    A. 1
    Explanation
    A C++ function can return only one value. Unlike other programming languages, C++ does not support multiple return values from a function. Therefore, the correct answer is 1.

    Rate this question:

  • 12. 

    If a function in C++ does not return a value then its return type is denoted as

    • A.

      Float

    • B.

      Void

    • C.

      Int

    • D.

      None of the Above

    Correct Answer
    B. Void
    Explanation
    In C++, when a function does not return a value, its return type is denoted as "void". The "void" keyword is used to indicate that the function does not return any value. This is often used for functions that perform certain actions or tasks without needing to return a result.

    Rate this question:

  • 13. 

    The variables that are used to represent individual array element in an array is called as

    • A.

      Pointer Variable

    • B.

      Subscripted variable

    • C.

      Index Variable

    • D.

      Real Variable

    Correct Answer
    B. Subscripted variable
    Explanation
    The variables that are used to represent individual array elements in an array are called subscripted variables. These variables are used to access specific elements within the array by using their corresponding indices. The indices are typically integers that indicate the position of the element within the array. By using subscripted variables, programmers can easily manipulate and retrieve specific data from arrays.

    Rate this question:

  • 14. 

    The array exforsys[10] can be declared using pointers as

    • A.

      % exforsys[]

    • B.

      & exforsys[]

    • C.

      * exforsys[]

    • D.

      @ exforsys[]

    Correct Answer
    C. * exforsys[]
    Explanation
    The correct answer is * exforsys[]. This is because declaring an array using pointers requires the use of the asterisk (*) symbol before the array name. Therefore, * exforsys[] is the correct syntax for declaring the array exforsys[10] using pointers.

    Rate this question:

  • 15. 

    What is the notation used to place a block of statements in a looping structure in C++?

    • A.

      % %

    • B.

      ( )

    • C.

      { }

    • D.

      None of the Above

    Correct Answer
    C. { }
    Explanation
    The correct answer is { }. In C++, a block of statements is enclosed within curly braces { } to define the body of a looping structure. These braces define the scope of the loop and allow multiple statements to be executed repeatedly until the loop condition is satisfied. The use of curly braces helps in organizing and grouping the statements within the loop, making the code more readable and maintainable.

    Rate this question:

  • 16. 

    Index of an array starts from

    • A.

      One

    • B.

      Zero

    • C.

      Two

    • D.

      None of the Above

    Correct Answer
    B. Zero
    Explanation
    The index of an array in most programming languages starts from zero. This means that the first element of an array is accessed using the index zero, the second element with index one, and so on. Therefore, the correct answer is "Zero".

    Rate this question:

  • 17. 

    The variable that contains address of another variable is called as

    • A.

      Pointer

    • B.

      Arrays

    • C.

      Unions

    • D.

      None of the Above

    Correct Answer
    A. Pointer
    Explanation
    A pointer is a variable that stores the memory address of another variable. It allows us to indirectly access and manipulate the value of the variable it points to. In this case, the correct answer is "pointer" because it accurately describes a variable that contains the address of another variable. Arrays and unions are different concepts and do not specifically refer to a variable that holds the address of another variable. Therefore, they are not the correct answers.

    Rate this question:

  • 18. 

    The operator that denotes address of a variable in C++ program is

    • A.

      *

    • B.

      %

    • C.

      $

    • D.

      &

    Correct Answer
    D. &
    Explanation
    The operator that denotes the address of a variable in C++ program is the ampersand symbol (&). This operator is used to retrieve the memory address of a variable, allowing for manipulation and access to that memory location.

    Rate this question:

  • 19. 

    The notation of member access operator in structures is

    • A.

      &

    • B.

      .

    • C.

      $

    • D.

      *

    Correct Answer
    B. .
    Explanation
    The correct answer is ".". In C programming, the dot (.) operator is used to access the members of a structure. It is used to refer to a particular variable or function within the structure. For example, if we have a structure called "person" with members such as name and age, we can access them using the dot operator like person.name or person.age.

    Rate this question:

  • 20. 

    One argument constructor is also called as

    • A.

      Single constructor

    • B.

      Copy constructor

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    B. Copy constructor
    Explanation
    A one-argument constructor is not called a "single constructor" because it can have multiple parameters. It is also not called a "copy constructor" because a copy constructor is a special type of constructor that takes an object of the same class as its parameter. Therefore, the correct answer is "None of the Above".

    Rate this question:

  • 21. 

    The other name for external variables in C++ is

    • A.

      Static variables

    • B.

      Register variables

    • C.

      Global variables

    • D.

      None of the Above

    Correct Answer
    C. Global variables
    Explanation
    The other name for external variables in C++ is global variables. In C++, global variables are declared outside of any function and can be accessed by any function within the program. They have a global scope and can be used throughout the entire program.

    Rate this question:

  • 22. 

    What method is used for writing characters in a C++ program? 

    • A.

      Put

    • B.

      Get

    • C.

      Write

    • D.

      None of the Above

    Correct Answer
    A. Put
    Explanation
    The put method is used for writing characters in a C++ program.

    Rate this question:

  • 23. 

    What will be the return type for a function named as exforsys declared as int exforsys (float x, double y)?

    • A.

      Double

    • B.

      Int

    • C.

      Float

    • D.

      None of the Above

    Correct Answer
    B. Int
    Explanation
    The return type for the function named "exforsys" is int because the function declaration states that the return type is int. The function takes two parameters, a float x and a double y, but the return type is specifically defined as int.

    Rate this question:

  • 24. 

    Which of the following options denotes the newline character in the C++ program?

    • A.

      '\n'

    • B.

      '/n'

    • C.

      'nc'

    • D.

      '/nc'

    Correct Answer
    A. '\n'
    Explanation
    The correct answer is ''\n''. In C++, the escape sequence '\n' represents the newline character. When this escape sequence is used in a program, it creates a new line and moves the cursor to the beginning of the next line.

    Rate this question:

  • 25. 

    Which of the following is used to group a set of global classes, objects and functions under a name?

    • A.

      Area named

    • B.

      Namearea

    • C.

      Namespaces

    • D.

      None of the above

    Correct Answer
    C. Namespaces
    Explanation
    Namespaces are used to group a set of global classes, objects, and functions under a name. They provide a way to organize code and prevent naming conflicts by encapsulating them within a specific scope. By using namespaces, different parts of a program can have their own separate set of names without interfering with each other. This helps in maintaining code clarity, modularity, and reusability.

    Rate this question:

  • 26. 

    Cin in C++ program uses the operator

    • A.

      >>

    • B.

    • C.

    • D.

      >

    Correct Answer
    A. >>
    Explanation
    In C++ programming, the "cin" statement is used to read input from the user. It uses the ">>" operator to extract data from the input stream and store it into variables. The ">>" operator is known as the extraction operator and it is used specifically with "cin" to read different types of data such as integers, floating-point numbers, characters, and strings.

    Rate this question:

  • 27. 

    Which of the following values denotes an incorrect data type in C++?

    • A.

      Real

    • B.

      Double

    • C.

      Float

    • D.

      Int

    Correct Answer
    A. Real
    Explanation
    In C++, there is no data type called "real." The correct data types for representing real numbers with decimal points are "double" and "float." "double" is used for double-precision floating-point numbers, while "float" is used for single-precision floating-point numbers. "int" is used for integers. Therefore, "real" is not a valid data type in C++.

    Rate this question:

  • 28. 

    The class that reads and writes to an array in memory is called ______. 

    • A.

      Ostream

    • B.

      Ifstream

    • C.

      Strstream

    • D.

      None of the Above

    Correct Answer
    C. Strstream
    Explanation
    The class that reads and writes to an array in memory is called strstream.

    Rate this question:

  • 29. 

    The new operator in C++

    • A.

      Initialize the allocated memory

    • B.

      Allocates memory for the object

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    C. Both A and B
    Explanation
    The correct answer is "Both A and B" because the new operator in C++ not only allocates memory for the object but also initializes the allocated memory. This means that when using the new operator to create an object, both memory allocation and initialization are performed automatically.

    Rate this question:

  • 30. 

    What notation is used to represent destructors in the C++ program? 

    • A.

      !

    • B.

      &

    • C.

      *

    • D.

      ~

    Correct Answer
    D. ~
    Explanation
    The tilde (~) notation is used to represent destructors in the C++ program. Destructors are special member functions that are automatically called when an object goes out of scope or is explicitly deleted. They are used to clean up any resources or memory allocated by the object. The tilde (~) followed by the class name is used to define the destructor in C++ code.

    Rate this question:

  • 31. 

    Virtual functions are defined in

    • A.

      Derived class

    • B.

      Base class

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    A. Derived class
    Explanation
    Virtual functions are defined in the derived class. This is because virtual functions are used in polymorphism, where different derived classes can have their own implementation of the same function declared in the base class. By defining the virtual function in the derived class, it allows for dynamic binding and the correct implementation of the function to be called based on the object's type at runtime.

    Rate this question:

  • 32. 

    Which of the following notations will you use to compare two variables X and Y?

    • A.

      X==Y

    • B.

      X=Y

    • C.

      X!=Y

    • D.

      X equals Y

    Correct Answer
    A. X==Y
    Explanation
    The correct answer is X==Y. This is the correct notation to use when comparing two variables X and Y. The double equals sign (==) is used in many programming languages to check if two values are equal. It returns a boolean value of true if the variables are equal and false if they are not. The other notations provided are not correct for comparing variables.

    Rate this question:

  • 33. 

    Comments in C++ program is written by using:

    • A.

      //

    • B.

      /* /*

    • C.

      * *

    Correct Answer
    A. //
    Explanation
    In C++ programming, comments are written using the double forward slash "//". This is a single-line comment that allows programmers to add explanatory or descriptive text within their code. The compiler ignores anything written after the "//" symbol, treating it as a comment and not executing it as code. This is useful for documenting the code, making it easier for other programmers to understand and maintain the code in the future.

    Rate this question:

  • 34. 

    Which of the following is mandatory for all C++ program?

    • A.

      Main()

    • B.

      Scanf()

    • C.

      System()

    • D.

      All the Above

    Correct Answer
    A. Main()
    Explanation
    The correct answer is "main()". In C++, the main() function is mandatory for every program. It serves as the entry point of the program, where the execution begins. Without the main() function, the program will not be able to run or execute any code. Therefore, main() is essential and required in all C++ programs.

    Rate this question:

  • 35. 

    Which of the following is returned by the operating system if a C++ program completes successfully?

    • A.

      No Value Returned

    • B.

      -1

    • C.

      1

    • D.

      0

    Correct Answer
    D. 0
    Explanation
    The operating system returns 0 if a C++ program completes successfully. This is a convention followed by most operating systems, where a return value of 0 indicates successful execution of the program.

    Rate this question:

  • 36. 

    Which of the following is used in C++ to create a copy of an object?

    • A.

      Assignment operator

    • B.

      Copy constructor

    • C.

      Both A) and B)

    • D.

      None of the Above

    Correct Answer
    B. Copy constructor
    Explanation
    The copy constructor in C++ is used to create a copy of an object. It is a special constructor that takes an object of the same class as a parameter and creates a new object with the same values. This is useful when we want to create a new object that is an exact copy of an existing object. The assignment operator can also be used to create a copy of an object, but it is not specifically designed for this purpose like the copy constructor is. Therefore, the correct answer is B) Copy constructor.

    Rate this question:

  • 37. 

    Which of the following exists in C++?

    • A.

      Virtual destructor

    • B.

      Virtual constructor

    • C.

      Both A and B

    • D.

      None of the Above

    Correct Answer
    A. Virtual destructor
    Explanation
    In C++, a virtual destructor exists. A virtual destructor is used to ensure that the destructor of a derived class is called when deleting a base class pointer that points to a derived class object. This is important to avoid memory leaks and ensure proper cleanup of resources allocated in the derived class. A virtual constructor, on the other hand, does not exist in C++. Therefore, the correct answer is virtual destructor.

    Rate this question:

  • 38. 

    Which of the following denote advantages of inheritance?

    • A.

      Saves program development time

    • B.

      Code reusability

    • C.

      Both A and B

    • D.

      All the Above

    Correct Answer
    C. Both A and B
    Explanation
    Inheritance in programming allows for the reuse of code, as it allows a class to inherit properties and methods from another class. This promotes code reusability and saves time in program development, as developers do not need to write the same code multiple times. Therefore, the correct answer is "Both A and B," as both advantages mentioned in options A and B are true.

    Rate this question:

Samy Boulos |MSc (Computer Science) |
Data Engineer
Samy Boulos is an experienced Technology Consultant with a diverse 25-year career encompassing software development, data migration, integration, technical support, and cloud computing. He leverages his technical expertise and strategic mindset to solve complex IT challenges, delivering efficient and innovative solutions to clients.

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jun 17, 2024
    Quiz Edited by
    ProProfs Editorial Team

    Expert Reviewed by
    Samy Boulos
  • Jan 12, 2011
    Quiz Created by
    Andreeahrab
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.