R4RIN
MCQS
C/C MCQ Quiz Hub
C Programming - References
Choose a topic to test your knowledge and improve your C/C skills
1. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int x = 80; int y& = x; x++; cout << x << "" "" << --y; return 0; }
The program will print the output 80 80.
The program will print the output 81 80.
The program will print the output 81 81.
It will result in a compile time error.
2. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int x = 80; int &y = x; x++; cout << x << " " << --y; return 0; }
The program will print the output 80 80.
The program will print the output 81 80.
The program will print the output 81 81.
. It will result in a compile time error.
3. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int x = 10; int &y = x; x++; cout<< x << " " << y++; return 0; }
The program will print the output 11 12.
The program will print the output 12 11.
The program will print the output 12 13.
It will result in a compile time error
4. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int x = 10; int &y = x; x = 25; y = 50; cout<< x << " " << --y; return 0; }
The program will print the output 25 49.
It will result in a compile time error.
The program will print the output 50 50.
The program will print the output 49 49
5. Which of the following statement is correct about the program given below? #include<iostream.h> enum bix { a=1, b, c }; int main() { int x = c; int &y = x; int &z = x; y = b; cout<< z--; return 0; }
It will result in a compile time error.
The program will print the output 1.
The program will print the output 2.
The program will print the output 3.
6. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int x = 10, y = 20; int *ptr = &x; int &ref = y; *ptr++; ref++; cout<< x << " " << y; return 0; }
The program will print the output 10 20.
The program will print the output 10 21.
The program will print the output 11 20.
The program will print the output 11 21.
7. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int x = 0; int &y = x; y = 5; while(x <= 5) { cout<< y++ << " "; x++; } cout<< x; return 0; }
The program will print the output 5 6 7 8 9 10.
The program will print the output 5 6 7 8 9 10 7.
The program will print the output 5 7.
It will result in a compile time error.
8. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int m = 2, n = 6; int &x = m; int &y = n; m = x++; x = m++; n = y++; y = n++; cout<< m << " " << n; return 0; }
The program will print output 2 6.
The program will print output 3 7.
The program will print output 4 8.
The program will print output 5 9.
9. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int m = 2, n = 6; int &x = m++; int &y = n++; m = x++; x = m++; n = y++; y = n++; cout<< m << " " << n; return 0; }
The program will print output 3 7.
The program will print output 4 8.
The program will print output 5 9.
It will result in a compile time error.
10. What will be the output of the following program? #include<iostream.h> class BixTest { public: BixTest(int &x, int &y) { x++; y++; } }; int main() { int a = 10, b = 20; BixTest objBT(a, b); cout<< a << " " << b; return 0; }
10 20
1121
Garbage Garbage
It will result in a compile time error.
11. Which of the following statement is correct about the program given below? #include<iostream.h> enum xyz { a, b, c }; int main() { int x = a, y = b, z = c; int &p = x, &q = y, &r = z; p = ++x; q = ++y; r = ++c; cout<< p << q << r; return 0; }
The program will print the output 1 2 3.
The program will print the output 2 3 4.
The program will print the output 0 1 2.
It will result in a compile time error.
12. Which of the following statement is correct about the program given below? #include<iostream.h> int main() { int arr[] = {1, 2 ,3, 4, 5}; int &zarr = arr; for(int i = 0; i <= 4; i++) { arr[i] += arr[i]; } for(i = 0; i <= 4; i++) cout<< zarr[i]; return 0; }
The program will print the output 1 2 3 4 5.
The program will print the output 2 4 6 8 10.
The program will print the output 1 1 1 1 1.
It will result in a compile time error.
13. Which of the following statement is correct about the program given below? #include<iostream.h> struct Bix { short n; }; int main() { Bix b; Bix& rb = b; b.n = 5; cout << b.n << " " << rb.n << " "; rb.n = 8; cout << b.n << " " << rb.n; return 0; }
It will result in a compile time error.
The program will print the output 5 5 5 8.
The program will print the output 5 5 8 8.
The program will print the output 5 5 5 5.
14. What will be the output of the following program? #include <iostream.h> enum xyz { a, b, c }; int main() { int x = a, y = b, z = c; int &p = x, &q = y, &r = z; p = z; p = ++q; q = ++p; z = ++q + p++; cout<< p << " " << q << " " << z; return 0; }
2 3 6
4 4 7
4 5 8
3 4 6
15. Which of the following statement is correct about the program given below? #include<iostream.h> int BixFunction(int m) { m *= m; return((10)*(m /= m)); } int main() { int c = 9, *d = &c, e; int &z = e; e = BixFunction(c-- % 3 ? ++*d :(*d *= *d)); z = z + e / 10; cout<< c << " " << e; return 0; }
It will result in a compile time error.
The program will print the output 64 9.
The program will print the output 64 10.
The program will print the output 64 11.
16. Which of the following statement is correct about the program given below? #include<iostream.h> class Bix { int x, y; public: Bix(int x, int y) { this->x = x; this->y = y; } void Display() { cout<< x << " " << y; } }; int main() { int x = 50; int &y = x ; Bix b(y, x); return 0; }
The program will print the output 50 50.
The program will print the two garbage values.
It will result in a compile time error.
The program will print nothing.
17. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x, y; public: void SetValue(int &xx, int &yy) { x = xx++; y = yy; cout<< xx << " " << yy; } }; int main() { int x = 10; int &y = x; IndiaBix objBix; objBix.SetValue(x , y); return 0; }
The program will print the output 10 10.
The program will print the output 10 11.
The program will print the output 11 10.
The program will print the output 11 11.
18. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x, y; public: void SetValue(int &a, int &b) { a = 100; x = a; y = b; Display(); } void Display() { cout<< x << " " << y; } }; int main() { int x = 10; IndiaBix objBix; objBix.SetValue(x, x); return 0; } A. B. The program will print the output 100 100. C. The program will print the output 100 garbage. D. The program will print two garbage values. E. It will result in a compile time error. A. The program will print the output 10 10. B. The program will print the output 10 11. C. The program will print the output 11 11. D. The program will print the output 11 10.
The program will print the output 100 10.
The program will print the output 100 100.
The program will print the output 100 garbage.
The program will print two garbage values.
19. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x, y; public: void SetValue(int &xx, int &yy) { x = xx ++; y = yy; Display(); } void Display() { cout<< x << " " << y; } }; int main() { int x = 10; int &y = x; IndiaBix objBix; objBix.SetValue(x , y); return 0; }.
The program will print the output 10 10.
The program will print the output 10 11.
The program will print the output 11 11.
The program will print the output 11 10.
20. Which of the following statement is correct about the program given below? #include<iostreamh> class IndiaBix { int x, y; public: IndiaBix(int &xx, int &yy) { x = xx; y = yy; Display(); } void Display() { cout<< x << " " << y; } }; int main() { int x1 = 10; int &p = x1; int y1 = 20; int &q = y1; IndiaBix objBix(p, q); return 0;
It will result in a compile time error. C. The program will print two garbage values. D.
It will result in a compile time error.
The program will print two garbage values
The program will print the address of variable x1 and y1.
21. Which of the following statement is correct about the program given below? #include<iostream.h> int i, j; class IndiaBix { public: IndiaBix(int x = 0, int y = 0) { i = x; j = x; Display(); } void Display() { cout<< j <<" "; } }; int main() { IndiaBix objBix(10, 20); int &s = i; int &z = j; i++; cout<< s-- << " " << ++z; return 0;
The program will print the output 0 11 21.
The program will print the output 10 11 11.
The program will print the output 10 11 21.
The program will print the output 10 11 12.
22. Which of the following statement is correct about the program given below? #include<iostream.h> int x, y; class BixTest { public: BixTest(int xx = 0, int yy = 0) { x = xx; y = yy; Display(); } void Display() { cout<< x << " " << y << " "; } }; int main() { BixTest objBT(10, 20); int &rx = x; int &ry = y; ry = x; rx = y; cout<< rx--; return 0; }
The program will print the output 0 0 10.
The program will print the output 10 20 10.
The program will print the output 10 20 9.
It will result in a compile time error.
23. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int a, b, c; public: void SetValue(int x, int y ,int z) { a = x; b = y; c = z; } void Display() { cout<< a << " " << b << " " << c; } }; int main() { IndiaBix objBix; int x = 2; int &y = x; y = 5; objBix.SetValue(x, ++y, x + y); objBix.Display(); return 0; }
The program will print the output 5 6 10.
The program will print the output 6 6 10.
The program will print the output 6 6 12.
It will result in a compile time error.
24. What will be the output of the program given below? #include<iostream.h> class BixBase { int x; public: BixBase(int xx = 0) { x = xx; } void Display() { cout<< x ; } }; class BixDerived : public BixBase { int y; public: BixDerived(int yy = 0) { y = yy; } void Display() { cout<< y ; } }; int main() { BixBase objBase(10); BixBase &objRef = objBase; BixDerived objDev(20); objRef = objDev; objDev.Display(); return 0; }
0
10
20
Garbage-value
25. Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x, y; public: IndiaBix(int xx = 0, int yy = 0) { x = xx; y = yy; } void Display() { cout<< x << " " << y; } IndiaBix operator +(IndiaBix z) { IndiaBix objTemp; objTemp.x = x + z.x; objTemp.y = y + z.y; return objTemp; } }; int main() { IndiaBix objBix1(90, 80); IndiaBix objBix2(10, 20); IndiaBix objSum; IndiaBix &objRef = objSum; objRef = objBix1 + objBix2; objRef.Display(); return 0; }
It will result in a runtime error.
It will result in a compile time error.
The program will print the output 9 4.
The program will print the output 100 100.
Submit