C++ Programming - Functions

Exercise : Functions - Programs
16.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
long FactFinder(long = 5); 
int main()
{
    for(int i = 0; i<= 0; i++)
        cout<< FactFinder() << endl; 
    return 0;
}
long FactFinder(long x)
{
    if(x < 2)
        return 1; 
    long fact = 1; 
    for(long i = 1; i <= x-1; i++)
        fact = fact * i; 
    return fact; 
}
The program will print the output 1.
The program will print the output 24.
The program will print the output 120.
The program will print the output garbage value.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

17.
What will be the output of the following program?
#include<iostream.h>
double BixFunction(double, double, double = 0, double = 0, double = 0);
int main()
{
    double d = 2.3;
    cout<< BixFunction(d, 7) << " ";
    cout<< BixFunction(d, 7, 6) << endl;
    return 0; 
}
double BixFunction(double x, double p, double q, double r, double s)
{
    return p +(q +(r + s * x)* x) * x;
}
7 20
7 19.8
7 Garbage
7 20.8
Answer: Option
Explanation:
No answer description is available. Let's discuss.

18.
What will be the output of the following program?
#include<iostream.h> 
int main()
{
    float Amount;
    float Calculate(float P = 5.0, int N = 2, float R = 2.0);
    Amount = Calculate(); 
    cout<< Amount << endl; 
    return 0;
}

float Calculate(float P, int N, float R)
{
    int Year = 1;
    float Sum = 1 ;
    Sum = Sum * (1 + P * ++N * R);
    Year =  (int)(Year + Sum);
    return Year; 
}
21
22
31
32
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.

19.
What will be the output of the following program?
#include<iostream.h> 
class Bix
{
    int x, y; 
    public:
    void show(void);
    void main(void);
};
void Bix::show(void)
{ 
    Bix b;
    b.x = 2;
    b.y = 4;
    cout<< x << " " << y;
}
void Bix::main(void)
{
    Bix b;
    b.x = 6; 
    b.y = 8;
    b.show();
}
int main(int argc, char *argv[])
{
    Bix run;
    run.main();
    return 0; 
}
2 4
6 8
The program will report error on Compilation.
The program will report error on Linking.
The program will report error on Run-time.
Answer: Option
Explanation:
No answer description is available. Let's discuss.

20.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class IndiabixSample
{
    private:
    int AdditionOne(int x, int y = 1) 
    {
        return x * y;
    }
     
    public:
    int AdditionTwo(int x, int y = 1)
    {
        return x / y;
    } 
}; 
int main()
{
    IndiabixSample objBix;
    cout<<objBix.AdditionOne(4, 8)<<" "; 
    cout<<objBix.AdditionTwo(8, 8); 
    return 0;
}
The program will print the output 32 0.
The program will print the output 32 garbage-value.
The program will print the output 32 1.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.