If the line: friend class A: appears in class B, and the line: friend class B: appears in class C. then: A) Class A is a friend of class C. B) Class A can access private variable Class B. C) Class C can call class A’s private member functions. D) Class B can access class A’s private variables. The correct function name for overloading the addition (+) operator is: A) operator+ B) operator(+) C) operator: + D) operator_+ Suppose you have a programmer-defined data type Data and want to overload the

## Expert Answer

Following are the answers for mcq’s

35) – B) Class A can access private variables of class B

36) – A) operator+

37) – A) ostream &operator<<(ostream &output, const Data &dataToPrint)

39) – A) automobile

40) – C) When these members should be available only to derived classes (and friends), not to other clients

41**)Programming Section:**

The procedure and the calculations to convert the given binary number to decimal and hexadecimal is shown in the image. Code has been explained using comments

**CODE:**

#include<bits/stdc++.h>

using namespace std;

int main(){

int binary_number,remainder,decimal=0,base=1;

cout<<“Enter binary number”<<endl;

cin >> binary_number;

//Binary to decimal conversion

while(binary_number>0){

remainder = binary_number%10; // Get last digit

decimal=decimal+remainder*base; //multiply last digit with base and add to decimal variable

base = base * 2; // base is initially 1 and is multiplied with 2 in each iteration

binary_number = binary_number/10; //last digit is removed

}//while ends

cout<<“Decimal= “<<decimal<<endl;

//Decimal to hexadecimal conversion

char hexadecimal[100]; //char array to store hex value

int i=0,j;

while(decimal>0){

remainder=decimal%16; //get remainder by dividing decimal by 16

// to convert integer into character

if(remainder<10){

remainder=remainder+48;

}

else{

remainder=remainder+55;

}

hexadecimal[i]=remainder; //store character equivalent

i++;

decimal=decimal/16;

}

cout<<“Hexadecimal =”;

for(j=i;j>=0; j–){

cout<<hexadecimal[j];

}

return 0;

}//main method ends

**Output:**

**Calculations****:**