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)
By Andreeahrab
A
Andreeahrab
Community Contributor
Quizzes Created: 1 | Total Attempts: 14,975
| Attempts: 14,975 | Questions: 38
Please wait...
Question 1 / 38
0 %
0/100
Score 0/100
1. Comments in C++ program is written by using:

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.

Submit
Please wait...
About This Quiz
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... see morewith 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. see less

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

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.

Submit
3. Cin in C++ program uses the operator

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.

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

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

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

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.

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

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.

Submit
7. Which of the following notations will you use to compare two variables X and 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.

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

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.

Submit
9. The variable that contains address of another variable is called as

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.

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

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.

Submit
11. Index of an array starts from

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

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

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.

Submit
13. Which of the following denotes the C++ looping statement?

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.

Submit
14. What is the notation used to place a block of statements in a looping structure in 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.

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

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.

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

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.

Submit
17. The other name for external variables in C++ is

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.

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

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.

Submit
19. The notation of ternary operator is

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.

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

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.

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

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.

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

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.

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

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.

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

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.

Submit
25. The notation of member access operator in structures is

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.

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

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.

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

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

Submit
28. Which of the following denote advantages of inheritance?

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.

Submit
29. A template can be instantiated by

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.

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

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.

Submit
31. The new operator in C++

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.

Submit
32. Strict parameter type checking is followed by which of these?

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.

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

Explanation

The put method is used for writing characters in a C++ program.

Submit
34. Virtual functions are defined in

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.

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

Explanation

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

Submit
36. One argument constructor is also called as

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

Submit
37. Which of the following exists in C++?

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.

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

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.

Submit
View My Results
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 (Updated): Jun 17, 2024 +

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
Cancel
  • All
    All (38)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Comments in C++ program is written by using:
Which of the following is mandatory for all C++ program?
Cin in C++ program uses the operator
Which of the following values denotes an incorrect data type in C++?
If a function in C++ does not return a value then its return type is...
The notation of logical NOT operator in a C++ program is
Which of the following notations will you use to compare two variables...
The variables that can be used only within the function in which it is...
The variable that contains address of another variable is called as
Which of the following options denotes the newline character in the...
Index of an array starts from
Which of the following is used to group a set of global classes,...
Which of the following denotes the C++ looping statement?
What is the notation used to place a block of statements in a looping...
What notation is used to represent destructors in the C++...
The minimum number of times a do loop would definitely get executed...
The other name for external variables in C++ is
When the object of the first class is instantiated then which of the...
The notation of ternary operator is
The array exforsys[10] can be declared using pointers as
The operator that denotes address of a variable in C++ program is
What will be the return type for a function named as exforsys declared...
Which of the following is used in C++ to create a copy of an object?
How many values can be returned by a C++ function?
The notation of member access operator in structures is
Which of the following is returned by the operating system if a C++...
For the class exforsys defined as below: class exforsys { }; int...
Which of the following denote advantages of inheritance?
A template can be instantiated by
Which of the following can be used to initialize a newly declared...
The new operator in C++
Strict parameter type checking is followed by which of these?
What method is used for writing characters in a C++ program? 
Virtual functions are defined in
The class that reads and writes to an array in memory is called...
One argument constructor is also called as
Which of the following exists in C++?
The variables that are used to represent individual array element in...
Alert!

Advertisement