Exercise: Functions
Questions for: Functions
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;
}
A:
21
B:
22
C:
31
D:
32
Answer: D
No answer description is available. Let's discuss.
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;
}
A:
7 20
B:
7 19.8
C:
7 Garbage
D:
7 20.8
Answer: D
No answer description is available. Let's discuss.
Discuss About this Question.
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;
}
A:
The program will print the output 1.
B:
The program will print the output 24.
C:
The program will print the output 120.
D:
The program will print the output garbage value.
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
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.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
const double BixConstant(const int, const int = 0);
int main()
{
const int c = 2 ;
cout<< BixConstant(c, 10)<< " ";
cout<< BixConstant(c, 20)<< endl;
return 0;
}
const double BixConstant(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.
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.