munotes®

BSc IT Sem I Programming with C Nov 2024 Question Paper with Solutions

MU B.Sc. (Information Technology) student group Free to join

Mumbai University Solved Question Papers munotes.in

Programming with C

BSc IT · Sem I

Nov 2024 Examination

Previous Year Question Paper with Solution

munotes.in Mumbai

munotes.in

First published on munotes.in on 12 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 Nov 2024 examination.

munotes.in ii
munotes.in iii

The Paper as Set

The questions in this volume are the questions asked at the Nov 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 1 hours  ·  Total marks 30  ·  8 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 iv

SECTION I

Q1)

Attempt any TWO · 15 Marks

munotes.in 1

A)Explain the working of a while loop in C language with example.

Answer

For full marks, cover: the syntax, the steps by which the loop runs, the three things every loop needs, that the body may run zero times, an example with a trace table, a second example with output, the infinite loop and how it happens, and how while differs from for and do-while.

What it is

A while loop repeats a statement as long as a condition is true. It is an entry-controlled loop: the condition is tested before each pass. It suits a loop whose number of passes is not known in advance.

Syntax

while (condition)

statement

If the body has more than one statement, it is written as a block in braces.

How it works

  1. The condition is tested.
munotes.in 2
  1. If it is true (non-zero), the body runs once.
  2. Control goes back to step 1, and the condition is tested again.
  3. When the condition is false (zero), the loop ends. Control passes to the statement after the loop.

The three things every loop needs

  1. Initialisation, before the loop: for example int n = 4721;.
  2. A condition that can become false: n > 0.
  3. Progress inside the body that moves towards making it false: n = n / 10;.

A loop that never ends is always missing the third.

Example: the sum of the digits of a number

#include <stdio.h>

int main(void) {

int n = 4721;

int sum = 0;

while (n > 0) {

sum = sum + n % 10;

n = n / 10;

munotes.in 3

}

printf("sum of the digits of 4721 = %d\n", sum);

int count = 5;

while (count >= 1) {

printf("%d...\n", count);

count--;

}

printf("Go! count is now %d\n", count);

return 0;

}

Output:

sum of the digits of 4721 = 14

5...

4...

3...

2...

1...

Go! count is now 0

munotes.in 4

Trace of the first loop

n before the testn > 0?n % 10sum after the bodyn after the body
4721true11472
472true2347
47true7104
4true4140
0falsenoneloop endsnone

n % 10 takes off the last digit and n / 10 removes it. The loop runs 4 times and tests its condition 5 times. The second loop counts down and stops when count reaches 0.

It may run zero times

Because the condition is tested first, the body may never run. With int n = 0;, the test n > 0 fails at once, and sum stays 0.

The infinite loop

If the progress step is missing, the condition never becomes false. For example, while (i <= 5) printf("%d\n", i); with no i++ prints the same number for ever. A semicolon after the brackets, while (i <= 5);, gives an empty body that also never ends.

munotes.in 5

while, for and do-while

LoopCondition testedLeast number of runsBest for
whilebefore each pass0an unknown number of passes
forbefore each pass0a known number of passes
do-whileafter each pass1a body that must run once, such as a menu

Conclusion. A while loop tests its condition before every pass and runs the body only while the condition is true. It needs an initialisation, a condition that can become false and progress in the body. Its body may run zero times, and a missing progress step makes it run for ever.

munotes.in 6

The rest of the answers

The first answer is free. The rest come with the B.Sc. (Information Technology) Semester 1 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!