C++ Programming - Functions

Exercise : Functions - Programs
21.
What will be the output of the following program?
#include<iostream.h> 
class IndiaBix
{
    int K; 
    public:
    void BixFunction(float, int , char);
    void BixFunction(float, char, char);
    
};
int main()
{
    IndiaBix objIB;
    objIB.BixFunction(15.09, 'A', char('A' + 'A'));
    return 0;
}
void IndiaBix::BixFunction(float, char y, char z)
{
    K = int(z);
    K = int(y);
    K = y + z;
    cout<< "K = " << K << endl; 
}
The program will print the output M = 130.
The program will print the output M = 195.
The program will print the output M = -21.
The program will print the output M = -61.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

22.
What will be the output of the following program?
#include<iostream.h> 
class TestDrive
{
    int x; 
    public:
    TestDrive(int xx)
    {
        x = xx;
    }
    int DriveIt(void);
};
int TestDrive::DriveIt(void)
{
    static int value = 0;
    int m;
    m = x % 2;
    x = x / 2;
    if((x / 2)) DriveIt(); 
    value = value + m * 10; 
    return value;
}
int main()
{
    TestDrive TD(1234);
    cout<< TD.DriveIt() * 10 << endl;
    return 0; 
}
300
200
Garbage value
400
Answer: Option
Explanation:
No answer description is available. Let's discuss.

23.
What will be the output of the following program?
#include<iostream.h> 
class IndiaBix
{
    int Num; 
    public:
    IndiaBix(int x)
    {
        Num = x;
    }
    int BixFunction(void);
};
int IndiaBix::BixFunction(void)
{
    static int Sum = 0; 
    int Dec;
    Dec = Num % 10; 
    Num = Num / 10; 
    if((Num / 100)) BixFunction(); 
    Sum  = Sum * 10 + Dec; 
    return Sum;
}
int main()
{
    IndiaBix objBix(12345);
    cout<< objBix.BixFunction();
    return 0; 
}
123
321
345
12345
54321
Answer: Option
Explanation:
No answer description is available. Let's discuss.

24.
What is correct about the following program?
#include<iostream.h> 
class Addition
{
    int x; 
    public: 
    Addition()
    {
        x = 0;
    }       
    Addition(int xx)
    {
        x = xx;
    }
    Addition operator + (int xx = 0)
    {
        Addition objTemp; 
        objTemp.x = x + xx; 
        return(objTemp);
    }
    void Display(void)
    {
        cout<< x << endl;
    }
};
int main()
{
    Addition objA(15), objB;
    objB = objA + 5;
    objB.Display();
    return 0; 
}
The program will print the output 20.
The program will report run time error.
The program will print the garbage value.
Compilation fails due to 'operator +' cannot have default arguments.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

25.
What will be the output of the following program?
#include<iostream.h> 
class AreaFinder
{
    float l, b, h; 
    float result; 
    public:
    AreaFinder(float hh = 0, float ll = 0, float bb = 0) 
    {
        l = ll; 
        b = bb; 
        h = hh;
    }
    void Display(int ll)
    {
        if(l = 0)
            result = 3.14f * h * h; 
        else
            result = l * b; 
        cout<< result; 
    }
};
int main()
{
    AreaFinder objAF(10, 10, 20);
    objAF.Display(0); 
    return 0; 
}
0
314
314.0000
200.0000
Answer: Option
Explanation:
No answer description is available. Let's discuss.