- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
- C++ Advanced
- C++ Files and Streams
- C++ Exception Handling
- C++ Dynamic Memory
- C++ Namespaces
- C++ Templates
- C++ Preprocessor
- C++ Signal Handling
- C++ Multithreading
- C++ Web Programming
C++ Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to C++ Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - One of the following is true for an inline function.
A - It executes faster as it is treated as a macro internally
B - It executes faster because it priority is more than normal function
C - It doesn’t executes faster compared to a normal function
Answer : A
Explaination
As inline function gets expanded at the line of call like a macro it executes faster.
Q 2 - A user defined header file is included by following statement in general.
Answer : A
Explaination
With the syntax as in (a) the compiler first looks for the file in the present working directory and then in the default include path if not found.
Q 3 - What is the output of the following program?
#include<iostream> using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<<r<<endl; }
Answer : C
Explaination
Comma is called as the separator operator and the associativity is from left to right. Therefore ‘k’ is the expressions resultant.
#include<iostream> using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<<r<<endl; }
Q 4 - Designer of C++ programming language.
Answer : D
Explaination
Answer : D
Explaination
Scope resolution operator is used to resolve for the global scope of a variable if the local and global variables conflict by name.
Q 6 - A C++ program statements can be commented using
Answer : D
Explaination
Both styles of commenting is available in C++.
Q 7 - What is the output of the following program?
#include<iostream> using namespace std; void f() { cout<<"Hello"<<endl; } main() { }
B - Error, as the function is not called.
C - Error, as the function is defined without its declaration
Answer : A
Explaination
No output, apart from the option (a) rest of the comments against the options are invalid
#include<iostream> using namespace std; void f() { cout<<"Hello"<<endl; } main() { }
Q 8 - What is the output of the following program?
#include<iostream> using namespace std; main() { int i = 13, j = 60; i^=j; j^=i; i^=j; cout<<i<<" "<<j; }
Answer : B
Explaination
60 13, its swapping.
#include<iostream> using namespace std; main() { int i = 13, j = 60; i^=j; j^=i; i^=j; cout<<i<<" "<<j; }
Answer : B
Explaination
g++ is GNU C++ compiler for linux. Borland and vc++ (Microsoft visual c++) for windows.
Q 10 - What is the output of the following program?
#include<iostream> #include<string.h> using namespace std; main() { char s[] = "Hello\0Hi"; cout<<strlen(s)<<" "<<sizeof(s); }
Answer : A
Explaination
Length of the string is count of character upto ‘\0’. sizeof – reports the size of the array.
#include<iostream> #include<string.h> using namespace std; main() { char s[] = "Hello\0Hi"; cout<<strlen(s)<<" "<<sizeof(s); }