Explore topic-wise MCQs in C++ Programming.

This section includes 70 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the output of this program?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool mygreater (int i,int j)
{
return (i > j);
}
int main ()
{
int Numbers[] = {45, 55, 55, 45, 65, 45, 55, 65};
vector<int> num(Numbers, Numbers + 8);
pair<vector<int> :: iterator, vector<int> :: iterator> Bound;
sort (num.begin(), num.end());
Bound = equal_range (num.begin(), num.end(), 65);
cout << (Bound.first - num.begin());
cout << " And " << (Bound.second - num.begin());
return 0;
}

A. 6
B. 8
C. 6 And 8
D. 8 And 6
E. None of these
Answer» D. 8 And 6
2.

What is the output of this program?
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
cout << min(200, 201) << ' ';
cout << min('U','L') << ' n';
return 0;
}

A. 201 U
B. U 201
C. L 200
D. 200 L
E. Compilation Error
Answer» E. Compilation Error
3.

What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
int value1, value2, value3;
public:
int get()
{
value1 = 100;
value2 = 350;
value3 = 450;
}
friend float Average(Example obj);
};
float Average(Example obj)
{
return float(obj.value1 + obj.value2 + obj.value3) / 3;
}
int main()
{
Example object;
object.get();
cout << Average(object);
return 0;
}

A. 100
B. 200
C. 300
D. Compilation Error
E. None of these
Answer» D. Compilation Error
4.

What is the output of this program?
#include <iostream>
using namespace std;
class Example;
class Example1
{
int W, H;
public:
int Area ()
{
return (W * H);}
void convert (Example p);
};
class Example
{
private:
int side;
public:
void set_side(int p)
{
side = p;
}
friend class Example1;
};
void Example1::convert (Example p)
{
W = p.side;
H = p.side;
}
int main ()
{
Example Square;
Example1 Rectangle;
Square.set_side(5);
Rectangle.convert(Square);
cout << Rectangle.Area();
return 0;
}

A. 36
B. 25
C. 16
D. 9
E. None of these
Answer» C. 16
5.

What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
int W, H;
public:
void set_values (int, int);
int RectArea () {return (W * H);}
friend Example duplicate (Example);
};
void Example::set_values (int p, int q)
{
W = p;
H = q;
}
Example duplicate (Example RectParameter)
{
Example Rect;
Rect.W = RectParameter.W * 2;
Rect.H = RectParameter.H * 3;
return (Rect);
}
int main ()
{
Example Rectangle, RectangleB;
Rectangle.set_values (2, 3);
RectangleB = duplicate (Rectangle);
cout << RectangleB.RectArea();
return 0;
}

A. 36
B. 3
C. 2
D. Compilation Error
E. None of these
Answer» B. 3
6.

What is the output of this program?
#include <iostream>
using namespace std;
class BoxExample
{
double W;
public:
friend void printW(BoxExample box );
void setW( double width );
};
void BoxExample::setW( double width )
{
W = width;
}
void printW(BoxExample box )
{
box.W = box.W * 3;
cout << "Width of box : " << box.W << endl;
}
int main( )
{
BoxExample box;
box.setW(15.0);
printW( box );
return 0;
}

A. 15
B. 3
C. 45
D. Compilation Error
E. None of these
Answer» D. Compilation Error
7.

What is the output of this program?
#include <iostream>
using namespace std;
class Example
{
private:
int p, q;
public:
void test()
{
p = 150;
q = 250;
}
friend int Calculate(Example Exmp1);
};
int Calculate(Example Exmp1)
{
return int(Exmp1.p + Exmp1.q) - 5;
}
int main()
{
Example obj;
obj.test();
cout << Calculate(obj);
return 0;
}

A. 250
B. 295
C. 150
D. 395
E. None of these
Answer» E. None of these
8.

What is the output of this program?
#include <iostream>
using namespace std;
int Calculate (int p, int q)
{
return (p * q);
}
float Calculate (float p, float q)
{
return (p / q);
}
int main ()
{
int var1 = 4, var2 = 3;
float num1 = 6.25, num2 = 5.35;
cout << Calculate (var1, var2);
cout << Calculate (num1, num2);
return 0;
}

A. 12 1.58
B. 12 0.005
C. Compilation Error
D. 12 1.25
E. None of these
Answer» E. None of these
9.

What is the output of this program?
#include 
using namespace std;
void function(int p, int q)
{
p = 30;
q = 12;
}
int main()
{
int p = 14;
function(p, p);
cout << p;
return 0;
}

A. 30
B. 12
C. 14
D. Compilation Error
E. None of these
Answer» D. Compilation Error
10.

What is the output of this program?
#include 
using namespace std;
class Newclass
{
public:
int k;
Newclass *operator->()
{return this;}
};
int main()
{
Newclass object;
object->k = 15;
cout << object.k << " " << object->k;
return 0;
}

A. 15
B. 15 15
C. Compilation Error
D. Runtime Error
E. None of these
Answer» C. Compilation Error
11.

What is the output of this program?
 #include <iostream> 
#include <functional>
#include <algorithm>
using namespace std;
int main ()
{
int num[] = {-12, -41, -15, -20, -10};
transform ( num, num + 2, num, negate<int>() );
for (int k = 0; k < 5; ++k)
cout << num[k] << " ";
}

A. 12
B. 12 41
C. 12 41 -15
D. 12 41 -15 -20
E. 12 41 -15 -20 -10
Answer» F.
12.

What is the output of this program?
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main ()
{
int FirstData[] = {23, 33, 43, 52, 56};
int SecondData[] = {2, 3, 4};
int Res[6];
transform ( FirstData, FirstData + 6, SecondData, Res, divides<int>());
for (int k = 0; k < 5; k++)
{
cout << Res[k] << " ";
}
return 0;
}

A. 11 11 10 2 1
B. 11 10 2 1
C. 10 2 1
D. 2 1
E. 1
Answer» B. 11 10 2 1
13.

What is the output of this program?
#include 
using namespace std;
void fun()
void fun()
{
cout< }
int main()
{
fun();
return 0;
}

A. Garbage value
B. Inteview Mania
C. Runtime Error
D. Compilation Error
E. None of these
Answer» E. None of these
14.

What is the output of this program?
#include <iostream>
using namespace std;
void duplicate (int& P, int& Q, int& R)
{
P *= 2;
Q *= 2;
R *= 2;
}
int main ()
{
int M = 2, N = 4, O = 6;
duplicate (M, N, O);
cout << M < return 0;
}

A. 4 8 12
B. 12 8 4
C. 8 12 4
D. Compilation Error
E. None of these
Answer» B. 12 8 4
15.

What is the output of this program?
 #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int num[] = {15, 25, 35, 35, 25, 15, 15, 25};
vector<int> VectorData(num, num + 8);
sort (VectorData.begin(), VectorData.end());
vector<int> :: iterator Lower, Upper;
Lower = lower_bound (VectorData.begin(), VectorData.end(), 35);
Upper = upper_bound (VectorData.begin(), VectorData.end(), 35);
cout << (Lower - VectorData.begin()) << ' ';
cout << (Upper - VectorData.begin()) << ' n';
return 0;
}

A. 15 25
B. 25 15
C. 6 8
D. 8 6
E. Compilation Error
Answer» D. 8 6
16.

What is the output of this program?
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main ()
{
int num[] = {11, -22, -33, 44, -55, 66, -1};
int Calculate;
Calculate = count_if ( num, num + 7, bind2nd(less<int>(), 0) );
cout << Calculate;
return 0;
}

A. 11
B. 4
C. -22
D. -33
E. -44
Answer» C. -22
17.

What is the output of this program?
#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main ()
{
vector <string*> num;
num.push_back ( new string ("First") );
num.push_back ( new string ("Second") );
num.push_back ( new string ("Third") );
num.push_back ( new string ("Fourth") );
num.push_back ( new string ("Fifth") );
vector <int> lengths ( num.size() );
transform (num.begin(), num.end(), lengths.begin(),
mem_fun(&string :: length));
for (int k = 0; k < 5; k++)
{
cout << lengths[k] << " ";
}
return 0;
}

A. 5 6 5 6 5
B. 6 5 6 5
C. 5 6 5
D. 6 5
E. 5
Answer» B. 6 5 6 5
18.

What is the output of this program?
#include <iostream>
using namespace std;
class ThreeDExample
{
int P, Q, R;
public:
ThreeDExample() { P = Q = R = 0; }
ThreeDExample(int m, int n, int o) { P = m; Q = n; R = o; }
ThreeDExample operator()(ThreeDExample obj);
ThreeDExample operator()(int num0, int num1, int num2);
friend ostream &operator< };
ThreeDExample ThreeDExample::operator()(ThreeDExample object)
{
ThreeDExample temp;
temp.P = (P + object.P) / 2;
temp.Q = (Q + object.Q) / 2;
temp.R = (R + object.R) / 2;
return temp;
}
ThreeDExample ThreeDExample::operator()(int num0, int num1, int num2)
{
ThreeDExample temp;
temp.P = P + num0;
temp.Q = Q + num1;
temp.R = R + num2;
return temp;
}
ostream &operator< strm << obj.P << ", " << obj.Q << ", " << obj.R << endl;
return strm;
}
int main()
{
ThreeDExample objectA(1, 2, 3), objectB(10, 10, 10), objectC;
objectC = objectA(objectB(50, 150, 250));
cout << objectC;
return 0;
}

A. 30, 81, 131
B. 81, 131, 30
C. 131, 81, 30
D. 81, 30, 131
E. None of these
Answer» B. 81, 131, 30
19.

What is the output of this program?
#include <iostream>
#include <algorithm>
using namespace std;
bool Function(int k, int L)
{
return k < L;
}
int main ()
{
int Array[ ] = {31, 17, 12, 51, 16, 14};
cout << *min_element(Array, Array + 6, Function) << " ";
cout << *max_element(Array, Array + 6, Function) ;
return 0;
}

A. 17 31
B. 31 17
C. 51 21
D. 12 51
E. Compilation Error
Answer» E. Compilation Error
20.

What will be the output of the following program? #include struct BixArray { int arr[5]; public: void BixFunction(); void Display(); }; void BixArray::BixFunction() { static int i = 0, j = 4; i++; j--; if(j > 0) BixFunction(); int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i--; j++; } void BixArray::Display() { for(int i = 0; i < 5; i++) cout<< arr[i] << " "; } int main() { BixArray objArr = {{5, 6, 3, 9, 0}}; objArr.BixFunction(); objArr.Display(); return 0; }

A. 5 6 3 9 0
B. 0 9 3 6 5
C. 0 5 6 3 9
D. 0 6 3 9 5
Answer» E.
21.

Which of the following statement is correct about the program given below? #include static double gDouble; static float gFloat; static double gChar; static double gSum = 0; class BaseOne { public: void Display(double x = 0.0, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class BaseTwo { public: void Display(int x = 1, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class Derived : public BaseOne, BaseTwo { void Show() { cout << gSum; } }; int main() { Derived objDev; objDev.BaseTwo::Display(10, 20, 'Z'); return 0; }

A. The program will print the output 0.
B. The program will print the output 120.
C. The program will report run-time error.
D. The program will report compile-time error.
Answer» E.
22.

Which of the following statement is correct about the program given below? #include 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.
Answer» D. The program will print the output 36.
23.

What is correct about the following program? #include class Base { int x, y, z; public: Base() { x = y = z = 0; } Base(int xx, int yy = 'A', int zz = 'B') { x = xx; y = x + yy; z = x + y; } void Display(void) { cout<< x << " " << y << " " << z << endl; } }; class Derived : public Base { int x, y; public: Derived(int xx = 65, int yy = 66) : Base(xx, yy) { y = xx; x = yy; } void Display(void) { cout<< x << " " << y << " "; Display(); } }; int main() { Derived objD; objD.Display(); return 0; }

A. The program will report compilation error.
B. The program will run successfully giving the output 66 65.
C. The program will run successfully giving the output 65 66.
D. The program will run successfully giving the output 66 65 65 131 196.
Answer» D. The program will run successfully giving the output 66 65 65 131 196.
24.

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» D. The program will print the output 12 Garbage b.
25.

What will be the output of the following program? #include 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; }

A. 2 4
B. 6 8
C. The program will report error on Compilation.
D. The program will report error on Linking.
Answer» C. The program will report error on Compilation.
26.

What will be the output of the following program? #include 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» E.
27.

What is correct about the following program? #include class Addition { int x; public: Addition() { x = 0; } Addition(int xx) { x = xx; } Addition operator + (int xx = 0) { Addition objTemp; objTemp.x = x + xx; return(objTemp); } void Display(void) { cout<< x << endl; } }; int main() { Addition objA(15), objB; objB = objA + 5; objB.Display(); return 0; }

A. The program will print the output 20.
B. The program will report run time error.
C. The program will print the garbage value.
D. Compilation fails due to 'operator +' cannot have default arguments.
Answer» E.
28.

Which of the following statement is correct about the program given below? #include class BixArray { int Matrix[3][3]; public: BixArray() { for(int i = 0; i<3; i++) for(int j = 0; j < 3; j++) Matrix[j][i] = i + j; } void Display(void) { for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cout<< Matrix[j][i] << " "; } }; int main() { BixArray objBix; objBix.Display(); return 0; }

A. The program will display the output 4 3 2 3 2 1 2 1 0.
B. The program will display the output 0 1 2 1 2 3 2 3 4.
C. The program will display the output 9 garbage values.
D. The program will report error on compilation.
Answer» C. The program will display the output 9 garbage values.
29.

What will be the output of the following program? #include class Base { public: int S, A, M; Base(int x, int y) { S = y - y; A = x + x; M = x * x; } Base(int, int y = 'A', int z = 'B') { S = y; A = y + 1 - 1; M = z - 1; } void Display(void) { cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { int x, y, z; public: Derived(int xx = 65, int yy = 66, int zz = 67): Base(x) { x = xx; y = yy; z = zz; } void Display(int n) { if(n) Base::Display(); else cout<< x << " " << y << " " << z << endl; } }; int main() { Derived objDev; objDev.Display(-1); return 0; }

A. 65 65 65
B. 65 66 67
C. A A A
D. A B C
Answer» B. 65 66 67
30.

What will be the output of the following program? #include class Base { public: char S, A, M; Base(char x, char y) { S = y - y; A = x + x; M = x * x; } Base(char, char y = 'A', char z = 'B') { S = y; A = y + 1 - 1; M = z - 1; } void Display(void) { cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { char x, y, z; public: Derived(char xx = 65, char yy = 66, char zz = 65): Base(x) { x = xx; y = yy; z = zz; } void Display(int n) { if(n) Base::Display(); else cout<< x << " " << y << " " << z << endl; } }; int main() { Derived objDev; objDev.Display(0-1); return 0; }

A. A A A
B. A B A
C. A B C
D. Garbage Garbage Garbage
Answer» B. A B A
31.

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» E.
32.

What will be the output of the following program? #include struct IndiaBix { int arr[5]; public: void BixFunction(void); void Display(void); }; void IndiaBix::Display(void) { for(int i = 0; i < 5; i++) cout<< arr[i] << " " ; } void IndiaBix::BixFunction(void) { static int i = 0, j = 4; int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp ; i++; j--; if(j != i) BixFunction(); } int main() { IndiaBix objBix = {{ 5, 6, 3, 9, 0 }}; objBix.BixFunction(); objBix.Display(); return 0; }

A. 0 9 3 6 5
B. 9 3 6 5 0
C. 5 6 3 9 0
D. 5 9 3 6 0
Answer» B. 9 3 6 5 0
33.

What will be the output of the following program? #include class BaseCounter { protected: long int count; public: void CountIt(int x, int y = 10, int z = 20) { count = 0; cout<< x << " " << y << " " << z << endl; } BaseCounter() { count = 0; } BaseCounter(int x) { count = x ; } }; class DerivedCounter: public BaseCounter { public: DerivedCounter() { } DerivedCounter(int x): BaseCounter(x) { } }; int main() { DerivedCounter objDC(30); objDC.CountIt(40, 50); return 0; }

A. 30 10 20
B. Garbage 10 20
C. 40 50 20
D. 20 40 50
Answer» D. 20 40 50
34.

What will be the output of the following program? #include class Base { int x, y; public: Base() { x = y = 0; } Base(int xx) { x = xx; } Base(int p, int q = 10) { x = p + q; y = q; } void Display(void) { cout<< x << " " << y << endl; } }objDefault(1, 1); class Derived: public Base { Base obj; public: Derived(int xx, int yy): Base(xx, xx + 1) { } Derived(Base objB = objDefault) { } }; int main() { Derived objD(5, 3); Derived *ptrD = new Derived(objD); ptrD->Display(); delete ptrD; return 0; }

A. 3 2
B. 8 3
C. 11 6
D. 11 10
Answer» D. 11 10
35.

Which of the following statement is correct about the program given below? #include #include #include class BixString { char txtName[20]; public: BixString(char *txtTemp = NULL) { if(txtTemp != NULL) strcpy(txtName, txtTemp); } void Display(void) { cout<

A. Above program will display IndiaBIX 8.
B. Above program will display IndiaBIX 9.
C. Above program will display size of integer.
D. Above program will display IndiaBIX and size of integer.
Answer» C. Above program will display size of integer.
36.

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» C. 3 14
37.

Which of the following statement is correct about the program given below? #include class IndiaBix { int x; float y; public: void BixFunction(int = 0, float = 0.00f, char = 'A'); void BixFunction(float, int = 10.00, char = 'Z'); void BixFunction(char, char, char); }; int main() { IndiaBix objBix; objBix.BixFunction(10 * 1.0, int(56.0)); return 0; } void IndiaBix::BixFunction(int xx, float yy, char zz) { x = xx + int(yy); cout<< "x = " << x << endl; } void IndiaBix::BixFunction(float xx, int yy, char zz) { x = zz + zz; y = xx + yy; cout<< " x = " << x << endl; } void IndiaBix::BixFunction(char xx, char yy, char zz) { x = xx + yy + zz; y = float(xx * 2); cout<< " x = " << x << endl; }

A. The program will print the output x = 65.
B. The program will print the output x = 66.
C. The program will print the output x = 130.
D. The program will print the output x = 180.
Answer» E.
38.

Which of the following statement is correct about the program given below? #include int BixTest(int x, int y); int BixTest(int x, int y, int z = 5); int main() { cout<< BixTest(2, 4) << endl; return 0; } int BixTest(int x, int y) { return x * y; } int BixTest(int x, int y, int z = 5) { return x * y * z; }

A. The program will print the output 5.
B. The program will print the output 8.
C. The program will print the output 40.
D. The program will report compile time error.
Answer» E.
39.

What will be the output of the following program? #include #include class IndiaBix { char txtMsg[50]; public: IndiaBix(char *str = NULL) { if(str != NULL) strcpy(txtMsg, str); } int BixFunction(char ch); }; int IndiaBix::BixFunction(char ch) { static int i = 0; if(txtMsg[i++] == ch) return strlen((txtMsg + i)) - i; else return BixFunction(ch); } int main() { IndiaBix objBix("Welcome to IndiaBix.com!"); cout<< objBix.BixFunction('t'); return 0; }

A. 6
B. 8
C. 9
D. 15
Answer» B. 8
40.

Which of the following statement is correct about the program given below? #include class BixArray { int array[3][3]; public: BixArray(int arr[3][3] = NULL) { if(arr != NULL) for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) array[i][j] = i+j; } void Display(void) { for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cout<< array[i][j] << " "; } }; int main() { BixArray objBA; objBA.Display(); return 0; }

A. The program will report error on compilation.
B. The program will display 9 garbage values.
C. The program will display NULL 9 times.
D. The program will display 0 1 2 1 2 3 2 3 4.
Answer» C. The program will display NULL 9 times.
41.

Which of the following statement is correct about the program given below? #include class IndiaBix { int x; float y; public: IndiaBix(int x) { x = x; } IndiaBix(int p = 0, int q = 10) { x = p += 2; y = q * 1.0f; } void SetValue(int &y, float z) { x = y; y = (int)z; } void Display(void) { cout<< x; } }; int main() { int val = 12; IndiaBix objBix(val); IndiaBix objTmp(); objBix.SetValue(val, 3.14f); objBix.Display(); return 0; }

A. The program will print the output 2.
B. The program will print the output 12.
C. The program will report run time error.
D. The program will not compile successfully.
Answer» E.
42.

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
D. 200
Answer» B. 314
43.

What will be the output of the following program? #include class Number { int Num; public: Number(int x = 0) { Num = x; } void Display(void) { cout<< Num; } void Modify(); }; void Number::Modify() { int Dec; Dec = Num % 13; Num = Num / 13; if(Num > 0 ) Modify() ; if(Dec == 10) cout<< "A" ; else if(Dec == 11) cout<< "B" ; else if(Dec == 12) cout<< "C" ; else if(Dec == 13) cout<< "D" ; else cout<< Dec ; } int main() { Number objNum(130); objNum.Modify(); return 0; }

A. 130
B. A0
C. B0
D. 90
Answer» C. B0
44.

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» E.
45.

What will be the output of the following program? #include class IndiaBix { int Num; public: IndiaBix(int x) { Num = x; } int BixFunction(void); }; int IndiaBix::BixFunction(void) { static int Sum = 0; int Dec; Dec = Num % 10; Num = Num / 10; if((Num / 100)) BixFunction(); Sum = Sum * 10 + Dec; return Sum; } int main() { IndiaBix objBix(12345); cout<< objBix.BixFunction(); return 0; }

A. 123
B. 321
C. 345
D. 12345
Answer» D. 12345
46.

What will be the output of the following program? #include class TestDrive { int x; public: TestDrive(int xx) { x = xx; } int DriveIt(void); }; int TestDrive::DriveIt(void) { static int value = 0; int m; m = x % 2; x = x / 2; if((x / 2)) DriveIt(); value = value + m * 10; return value; } int main() { TestDrive TD(1234); cout<< TD.DriveIt() * 10 << endl; return 0; }

A. 300
B. 200
C. Garbage value
D. 400
Answer» E.
47.

What will be the output of the following program? #include class IndiaBix { int x, y, z; public: void Apply(int xx = 12, int yy = 21, int zz = 9) { x = xx; y = yy += 10; z = x -= 2; } void Display(void) { cout<< x << " " << y << endl; } void SetValue(int xx, int yy) { Apply(xx, 0, yy); } }; int main() { IndiaBix *pBix= new IndiaBix; (*pBix).SetValue(12, 20); pBix->Display(); delete pBix; return 0; }

A. 10 10
B. 12 10
C. 12 21
D. 12 31
Answer» B. 12 10
48.

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» D. The program will print the output 21 29.
49.

Which of the following statement is correct about the program given below? #include void Tester(float xx, float yy = 5.0); class IndiaBix { float x; float y; public: void Tester(float xx, float yy = 5.0) { x = xx; y = yy; cout<< ++x % --y; } }; int main() { IndiaBix objBix; objBix.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.
Answer» E.
50.

Which of the following statement is correct about the program given below? #include 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» B. The program will print the output 20 40.