Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

C++ Programming

Cpp Programming Quiz 158 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
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; }

[A].0
[B].314
[C].314.0000
[D].200.0000 

Answer: Option A

Cpp Programming Quiz 158 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 159 – Which of the following statement is correct about the program given below?

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

#include
long GetNumber(long int Number)
{
return --Number;
}
float GetNumber(int Number)
{
return ++Number;
}
int main()
{
int x = 20;
int y = 30;
cout<< GetNumber(x) << " "; cout<< GetNumber(y) ; return 0; }

[A].The program will print the output 19 31.
[B].The program will print the output 20 30.
[C].The program will print the output 21 31.
[D].The program will print the output 21 29. 

Answer: Option C

Cpp Programming Quiz 159 – Which of the following statement is correct about the program given below? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 160 – Which of the following statement is correct about the program given below?

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

#include
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: Option C

Cpp Programming Quiz 160 – Which of the following statement is correct about the program given below? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 161 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
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: Option D

Cpp Programming Quiz 161 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 162 – Which of the following statement is correct about the program given below?

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

#include
static int b = 0;
void DisplayData(int *x, int *y = &b)
{
cout<< *x << " " << *y; } int main() { int a = 10, b = 20 ; DisplayData(&a, &b); return 0; }

[A].The program will print the output 10 20.
[B].The program will print the output 10 0.
[C].The program will print the output 10 garbage.
[D].The program will report compile time error. 

Answer: Option A

Cpp Programming Quiz 162 – Which of the following statement is correct about the program given below? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 163 – Which of the following statement is correct about the program given below?

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

#include
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<

[A].The program will print the output 32 0.
[B].The program will print the output 32 garbage-value.
[C].The program will print the output 32 1.
[D].The program will report compile time error. 

Answer: Option D

Cpp Programming Quiz 163 – Which of the following statement is correct about the program given below? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 164 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
struct MyData
{
public:
int Addition(int a, int b = 10)
{
return (a *= b + 2);
}
float Addition(int a, float b);
};
int main()
{
MyData data;
cout<

[A].12 12
[B].12 18
[C].3 14
[D].18 12 

Answer: Option B

Cpp Programming Quiz 164 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 165 – Which of the following statement will be correct if the function has three arguments passed to it?

Question: Which of the following statement will be correct if the function has three arguments passed to it?

[A]. The trailing argument will be the default argument.
[B]. The first argument will be the default argument.[C]. The middle argument will be the default argument.
[D]. All the argument will be the default argument.

Answer: Option A

Cpp Programming Quiz 165 – Which of the following statement will be correct if the function has three arguments passed to it? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 166 – What will be the output of the following program?

Question: What will be the output of the following program?

#include
class IndiabixSample
{
public:
int a;
float b;
void BixFunction(int a, float b, float c = 100.0f)
{
cout<< a % 20 + c * --b; } }; int main() { IndiabixSample objBix; objBix.BixFunction(20, 2.000000f, 5.0f); return 0; }

[A].0
[B].5
[C].100
[D].-5

Answer: Option B

Cpp Programming Quiz 166 – What will be the output of the following program? Read More »

Cpp Programming, Functions

Cpp Programming Quiz 167 – Which of the following statement is correct?

Question: Which of the following statement is correct?
[A].Two functions having same number of argument, order and type of argument can be overloaded if both functions do not have any default argument.
[B].Overloaded function must have default arguments.[C].Overloaded function must have default arguments starting from the left of argument list.
[D]A function can be overloaded more than once.

Answer: Option D

Cpp Programming Quiz 167 – Which of the following statement is correct? Read More »

Cpp Programming, Functions