munotes®

BSc CS Sem 2 Introduction to OOP using C++ Apr 2024 Question Paper with Solutions

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

munotes.in

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.

munotes.in ii

Contents

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

munotes.in iii
munotes.in iv

The Paper as Set

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.

munotes.in v

SECTION I

Q1)

Attempt any four: · 20 Marks

munotes.in 1

A)Explain bitwise operators in C++ with examples.[5]

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

Bitwise operators work on the individual bits (0s and 1s) of integer values, not on the whole number. C++ has six:

  1. & (AND): a bit of the result is 1 only if both bits are 1.
  2. The vertical bar (OR): a bit of the result is 1 if either bit is 1.
  3. ^ (XOR): a bit of the result is 1 if the two bits differ.
  4. ~ (NOT, the complement): turns each 1 into 0 and each 0 into 1.
  5. << (left shift): moves the bits left, filling with 0 on the right.
  6. >> (right shift): moves the bits right.
munotes.in 2

Worked example

Take a = 12 and b = 10. In eight bits, a is 00001100 and b is 00001010.

ExpressionBitsValue
a0000 110012
b0000 101010
a & b0000 10008
a ^ b0000 01106

a OR b is 0000 1110, which is 14. In C++ it is written with the vertical bar, a | b.

  • a << 2 moves every bit two places left: 0011 0000, which is 48. Each left shift multiplies by 2.
  • a >> 2 moves every bit two places right: 0000 0011, which is 3. Each right shift divides by 2, dropping the remainder.
  • ~a flips all the bits of the int. For a signed int this gives -13, because ~a equals -(a + 1).

Program

  1. #include <bitset>
  2. #include <iostream>
  3. using namespace std;
munotes.in 3
  1. int main() {
  2. int a = 12, b = 10;
  3. cout << "a = " << bitset<8>(a) << " (" << a << ")\n";
  4. cout << "b = " << bitset<8>(b) << " (" << b << ")\n";
  5. cout << "a & b = " << bitset<8>(a & b) << " (" << (a & b) << ")\n";
  6. cout << "a | b = " << bitset<8>(a | b) << " (" << (a | b) << ")\n";
  7. cout << "a ^ b = " << bitset<8>(a ^ b) << " (" << (a ^ b) << ")\n";
  8. cout << "~a = " << (~a) << '\n';
  9. cout << "a << 2 = " << bitset<8>(a << 2) << " (" << (a << 2) << ")\n";
  10. cout << "a >> 2 = " << bitset<8>(a >> 2) << " (" << (a >> 2) << ")\n";
  11. int n = 7;
  12. cout << n << " is " << ((n & 1) ? "odd" : "even") << '\n';
  13. return 0;
  14. }

Output:

munotes.in 4

a = 00001100 (12)
b = 00001010 (10)
a & b = 00001000 (8)
a | b = 00001110 (14)
a ^ b = 00000110 (6)
~a = -13
a << 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.

Uses

  1. Odd or even: n & 1 is 1 for an odd number, because its last bit is 1. The program shows that 7 is odd.
  2. Fast multiply and divide by 2: n << 1 doubles n, and n >> 1 halves it.
  3. Flags: several on or off settings can be kept in the bits of one integer, set with | 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.

munotes.in 5

The rest of the answers

The first answer is free. The rest come with the B.Sc. (Computer Science) Semester 2 solved papers.

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.

Issue

Found an error in this volume? Report it and we will check it against the paper.

Done!