Mumbai University Solved Question Papers munotes.in
Introduction to OOP using C++
BSc CS · Sem 2
Apr 2024 Examination
Previous Year Question Paper with Solution
munotes.in Mumbai
Mumbai University Solved Question Papers munotes.in
Introduction to OOP using C++
BSc CS · Sem 2
Apr 2024 Examination
Previous Year Question Paper with Solution
munotes.in Mumbai
First published on munotes.in on 12 November 2026.
This edition revised 13 November 2026.
Published by munotes.in, Mumbai.
Model answers written and edited by the munotes.in editorial desk.
Passages from this volume may be quoted, in print, online or by an AI system, with credit: name munotes.in and link to this volume's page. The volume may not be reproduced as a whole. Full terms at munotes.in/content-license.
munotes.in is an independent study resource for students of the University of Mumbai. It is not affiliated with the University of Mumbai, and is not endorsed by it.
The University does not publish an official answer key for this paper. The answers in this volume are model answers, written to show how a full-mark answer is built. They are a study aid, not an authority on what an examiner marked.
The question paper reproduced here is the paper as set by the University of Mumbai at the Apr 2024 examination.
The questions below are the paper as the University of Mumbai set it at the Apr 2024 examination, in the order it was set.
MarksPage
MarksPage
The questions in this volume are the questions asked at the Apr 2024 examination, reproduced as the University of Mumbai set them, in the order it set them. Nothing has been reworded, added or left out. Only the answers are ours. See the original question paper.
Duration 2½ hours · Total marks 75 · 24 questions answered
How to use this volume
Solve the paper first, under exam conditions and against the clock. Then read the answers here and mark your own. Reading a solution before attempting the question feels productive and teaches very little, because recognising an answer is not the same as being able to write one.
Q1)
Attempt any four: · 20 Marks
Answer
For full marks, cover: what bitwise operators work on; each of the six operators with its rule; a worked example in binary; a program; one or two uses.
Bitwise operators work on the individual bits (0s and 1s) of integer values, not on the whole number. C++ has six:
& (AND): a bit of the result is 1 only if both bits are 1.^ (XOR): a bit of the result is 1 if the two bits differ.~ (NOT, the complement): turns each 1 into 0 and each 0 into 1.<< (left shift): moves the bits left, filling with 0 on the right.>> (right shift): moves the bits right.Take a = 12 and b = 10. In eight bits, a is 00001100 and b is 00001010.
| Expression | Bits | Value |
|---|---|---|
a | 0000 1100 | 12 |
b | 0000 1010 | 10 |
a & b | 0000 1000 | 8 |
a ^ b | 0000 0110 | 6 |
a OR b is 0000 1110, which is 14. In C++ it is written with the vertical bar, a | b.
int. For a signed int this gives -13, because ~a equals -(a + 1).#include <bitset>#include <iostream>using namespace std;int main() { int a = 12, b = 10; cout << "a = " << bitset<8>(a) << " (" << a << ")\n"; cout << "b = " << bitset<8>(b) << " (" << b << ")\n"; cout << "a & b = " << bitset<8>(a & b) << " (" << (a & b) << ")\n"; cout << "a | b = " << bitset<8>(a | b) << " (" << (a | b) << ")\n"; cout << "a ^ b = " << bitset<8>(a ^ b) << " (" << (a ^ b) << ")\n"; cout << "~a = " << (~a) << '\n'; cout << "a << 2 = " << bitset<8>(a << 2) << " (" << (a << 2) << ")\n"; cout << "a >> 2 = " << bitset<8>(a >> 2) << " (" << (a >> 2) << ")\n"; int n = 7; cout << n << " is " << ((n & 1) ? "odd" : "even") << '\n'; return 0;}Output:
a = 00001100 (12)b = 00001010 (10)a & b = 00001000 (8)a | b = 00001110 (14)a ^ b = 00000110 (6)~a = -13a << 2 = 00110000 (48)a >> 2 = 00000011 (3)7 is odd
bitset<8>(x) from the header <bitset> prints a value as eight bits, so each result can be read in binary.
n & 1 is 1 for an odd number, because its last bit is 1. The program shows that 7 is odd.n << 1 doubles n, and n >> 1 halves it.| and tested with &.Conclusion. Bitwise operators work bit by bit on integers: &, | and ^ combine two values, ~ flips the bits, and << and >> shift them. For 12 and 10 they give 8, 14, 6, -13, 48 and 3.
The rest of the answers
You have read the question paper and its first answer in full. Buy the solved papers once and you can read every answer of every solved paper in this semester.
Notes + practical solutions + solved papers: ₹798 Already bought it? Sign in
Or solved papers only: ₹499
Or notes + practical solutions: ₹499
The question paper itself stays free, and so does the syllabus.
What should we fix or add?
Found an error in this volume? Report it and we will check it against the paper.