Professional Documents
Culture Documents
Write the output of any one of the two programs given below. (5) Roll No:
1. main() Section:
{
int n = 4, k = 2;
cout << ++n << endl;
cout << n << endl;
cout << n++ << endl;
cout << n << endl;
cout << -n << endl;
cout << --n << endl;
cout << n + k << endl;
cout << " " << n << endl;
cout << " n" << endl;
cout << "\n" << endl;
cout << " n * n = ";
}
2. main()
{
int n;
cout << (n = 4) << endl;
cout << (n == 4) << endl;
cout << (n > 3) << endl;
cout << (n < 4) << endl;
cout << (n = 0) << endl;
cout << (n == 0) << endl;
cout << (n > 0) << endl;
cout << (n && 4) << endl;
cout << (n || 4) << endl;
cout << (!n) << endl;
}
Answer any 5 of the multiple choice questions. Each correct answer will give 1 mark, while
incorrect answer will lead to deduction of 0.5 marks.
3. Which of the following statement is correct with respect to the use of friend keyword
inside a class?
a. A private data member can be declared as a friend.
b. A class may be declared as a friend.
c. An object may be declared as a friend.
d. We can use friend keyword as a class name.
4. Constructor is executed when _____.
a. an object is created
b. an object is used
c. a class is declared
d. an object goes out of scope