C++ Programming - Functions
Exercise : Functions - Programs
- Functions - General Questions
- 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;
}
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;
}
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;
}
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;
}
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;
}
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers