Void(C++ Programming ) Questions and Answers
Question 1.
What is the output of this program?
1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
void a = 10, b = 10;
6.
int c;
7.
c = a + b;
8.
cout
- 20
- compile time error
- runtime error
- none of the mentioned
Explanation:-
Answer: Option B. -> compile time errorvoid will not accept any values to its type.
Explanation:-
Answer: Option B. -> void is also used when the value of a pointer is null.void fundamental type is used in the cases of a and c.
Explanation:-
Answer: Option D. -> flags an errorThere are no void objects.
Explanation:-
Answer: Option D. -> none of the mentionedConstructor creats an Object and Destructor destroys the object. They are not supposed to return
anything, not even void.
Explanation:-
Answer: Option B. -> voidNone.