Programs (Set - 1)

Question 11 :

Which of the following statement is correct about the program given below?

#include < iostream . h >
void Tester(int xx, int yy = 5);
class IndiaParinam
{
    int x; 
    int y; 
    public:
    void Tester(int xx, int yy = 5)
    {
        x = xx;
        y = yy;
        cout<< ++x % --y; 
    }
};
int main()
{
    IndiaParinam objParinam;
    objParinam.Tester(5, 5);
    return 0; 
}


A). The program will print the output 0.
B). The program will print the output 1.
C). The program will print the output 2.
D). The program will print the output garbage value.
E). The program will report compile time error.
Answer : Option C

Question 12 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
class PowerFinder
{
    public:
    void Power(int x = 1, int y = 1)
    {
        int P = 1, i = 1;
        while(++i <= y)
        {
            P *= x;
        }
        cout<< P << endl; 
    } 
};
int main()
{
    PowerFinder FP; 
    FP.Power(2, 6); 
    return 0;
}


A). The program will print the output 12.
B). The program will print the output 16.
C). The program will print the output 32.
D). The program will print the output 36.
E). The program will execute infinite time.
Answer : Option C

Question 13 :

Which of the following statement is correct about the program given below?

#include < iostream . h >
void Tester(float xx, float yy = 5.0);
class IndiaParinam
{
    float x; 
    float y; 
    public:
    void Tester(float xx, float yy = 5.0)
    {
        x = xx;
        y = yy;
        cout<< ++x % --y; 
    }
};
int main()
{
    IndiaParinam objParinam;
    objParinam.Tester(5.0, 5.0);
    return 0; 
}


A). The program will print the output 0.
B). The program will print the output 1.
C). The program will print the output 2.
D). The program will print the output garbage value.
E). The program will report compile time error.
Answer : Option E

Question 14 :

Which of the following statement is correct about the program given below?

#include < iostream . h >
const double ParinamConstant(const int, const int = 0);
int main()
{
    const int c = 2 ;
    cout<< ParinamConstant(c, 10)<< " "; 
    cout<< ParinamConstant(c, 20)<< endl; 
    return 0;
}
const double ParinamConstant(const int x, const int y)
{
    return( (y + (y * x) * x % y) * 0.2);
}


A). The program will print the output 2 4.
B). The program will print the output 20 40.
C). The program will print the output 10 20.
D). The program will print the output 20 4.50.
E). The program will report compile time error.
Answer : Option A

Question 15 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
struct MyStructure
{
    class MyClass
    {
        public:
        void Display(int x, float y = 97.50, char ch = 'a')
        {
            cout<< x << " " << y << " " << ch;
        }
    }Cls; 
}Struc;
 
int main()
{
    Struc.Cls.Display(12, 'b');
    return 0; 
}


A). The program will print the output 12 97.50 b.
B). The program will print the output 12 97.50 a.
C). The program will print the output 12 98 a.
D). The program will print the output 12 Garbage b.
E). The program will print the output 12 Garbage a.
Answer : Option C