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.

51.

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» C. 100
52.

What will be the output of the following program? #include class IndiaBix { int K; public: void BixFunction(float, int , char); void BixFunction(float, char, char); }; int main() { IndiaBix objIB; objIB.BixFunction(15.09, 'A', char('A' + 'A')); return 0; } void IndiaBix::BixFunction(float, char y, char z) { K = int(z); K = int(y); K = y + z; cout<< "K = " << K << endl; }

A. The program will print the output M = 130.
B. The program will print the output M = 195.
C. The program will print the output M = -21.
D. The program will print the output M = -61.
Answer» E.
53.

Which of the following statement is correct about the program given below? #include static int Result; class India { public: void Change(int x = 10, int y = 20, int z = 30) { cout<< x + y + z; } void Display(int x = 40, float y = 50.00) { Result = x % x; cout<< Result; } }; class Bix { int x, y; public: void Change(int x, int y = 50) { cout<< x + y; } }; class IndiaBix: public India, public Bix { public: void Display(int x = 10, int xx = 100, int xxx = 1000) { Result = x + xx % x * x; cout<< Result ; } }; int main() { IndiaBix objBix; objBix.India::Display(10, 20.00); return 0; }

A. The program will print the output 0.
B. The program will print the output 10.
C. The program will print the output 30.
D. The program will print the output 40.
Answer» B. The program will print the output 10.
54.

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

What will be the output of the following program? #include int BixFunction(int a, int b = 3, int c = 3) { cout<< ++a * ++b * --c ; return 0; } int main() { BixFunction(5, 0, 0); return 0; }

A. 8
B. 6
C. -6
D. -8
Answer» D. -8
56.

What will be the output of the following program? #include #include class BixString { char x[50]; char y[50]; char z[50]; public: BixString() { } BixString(char* xx) { strcpy(x, xx); strcpy(y, xx); } BixString(char *xx, char *yy = " C++", char *zz = " Programming!") { strcpy(z, xx); strcat(z, yy); strcat(z, zz); } void Display(void) { cout<< z << endl; } }; int main() { BixString objStr("Learn", " Java"); objStr.Display(); return 0; }

A. Java Programming!
B. C++ Programming!
C. Learn C++ Programming!
D. Learn Java Programming!
Answer» E.
57.

Which of the following function declaration is/are incorrect?

A. int Sum(int a, int b = 2, int c = 3);
B. int Sum(int a = 5, int b);
C. int Sum(int a = 0, int b, int c = 3);
D. Both B and C are incorrect.
Answer» E.
58.

Which of the following function / type of function cannot be overloaded?

A. Member function
B. Static function
C. Virtual function
D. Both B and C
Answer» D. Both B and C
59.

Which of the following statement is correct about the program given below? #include void Tester(int xx, int yy = 5); class IndiaBix { int x; int y; public: void Tester(int xx, int yy = 5) { x = xx; y = yy; cout<< ++x % --y; } }; int main() { IndiaBix objBix; objBix.Tester(5, 5); 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» D. The program will print the output garbage value.
60.

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» B. The program will print the output 10 0.
61.

Which of the following statement is correct about the program given below? #include class IndiaBix { int x, y, z; public: IndiaBix(int x = 100, int y = 30, int z = 0) { this->x = x; this->y = y; this->z = z; Display(); } void Display() { cout<< x << " " << y << " " << z; } }; int main() { int a = 0, b = 1, c = 2; int &x = ++a; int &y = --b; int z = c + b - -c; IndiaBix objBix(x, y, z); return 0; }

A. The program will print the output 1 0 3.
B. The program will print the output 1 0 4.
C. The program will print the output 1 1 3.
D. The program will print the output 1 1 4.
Answer» C. The program will print the output 1 1 3.
62.

Which of the following statement is correct about the program given below? #include class IndiaBix { public: void Bix(int x = 15) { x = x/2; if(x > 0) Bix(); else cout<< x % 2; } }; int main() { IndiaBix objIB; objIB.Bix(); return 0; }

A. The program will display 1.
B. The program will display 2.
C. The program will display 15.
D. The program will go into an infinite loop.
Answer» E.
63.

What will be the output of the following program? #include class IndiaBix { public: int x, y; IndiaBix(int xx = 10, int yy = 20) { x = xx; y = yy; } void Exchange(int *, int *); }; int main() { IndiaBix objA(30, 40); IndiaBix objB(50); objA.Exchange(&objA.x, &objB.y); cout<< objA.x << " " << objB.y << endl; return 0; } void IndiaBix::Exchange(int *x, int *y) { int t; t = *x; *x = *y; *y = t ; }

A. 20 10
B. 30 20
C. 20 30
D. 30 40
Answer» D. 30 40
64.

What will be the output of the following program? #include void MyFunction(int a, int b = 40) { cout<< " a = "<< a << " b = " << b << endl; } int main() { MyFunction(20, 30); return 0; }

A. a = 20 b = 40
B. a = 20 b = 30
C. a = 20 b = Garbage
D. a = Garbage b = 40
Answer» C. a = 20 b = Garbage
65.

What will be the output of the following program? #include typedef void(*FunPtr)(int); int Look(int = 10, int = 20); void Note(int); int main() { FunPtr ptr = Note; (*ptr)(30); return 0; } int Look(int x, int y) { return(x + y % 20); } void Note(int x) { cout<< Look(x) << endl; }

A. 10
B. 20
C. 30
D. 40
Answer» D. 40
66.

What will be the output of the following program? #include long BixFunction(int x, int y = 5, float z = 5) { return(++x * ++y + (int)++z); } int main() { cout<< BixFunction(20, 10); return 0; }

A. 237
B. 242
C. 240
D. 35
Answer» B. 242
67.

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» B. The first argument will be the default argument.
68.

Which of the following function / types of function cannot have default parameters?

A. Member function of class
B. main()
C. Member function of structure
D. Both B and C
Answer» C. Member function of structure
69.

Where the default value of parameter have to be specified?

A. Function call
B. Function definition
C. Function prototype
D. Both B or C
Answer» D. Both B or C
70.

Which of the following function prototype is perfectly acceptable?

A. int Function(int Tmp = Show());
B. float Function(int Tmp = Show(int, float));
C. Both A and B.
D. float = Show(int, float) Function(Tmp);
Answer» B. float Function(int Tmp = Show(int, float));