Shiv Nadar University CSD101: Introduction To Computing and Programming Lab #3 Number Based Basic C Programs
Shiv Nadar University CSD101: Introduction To Computing and Programming Lab #3 Number Based Basic C Programs
Shiv Nadar University CSD101: Introduction To Computing and Programming Lab #3 Number Based Basic C Programs
1. (a) Write a program that reads two integers m and n (either or both could be negative) and prints the
quotient and the remainder when m is divided by n. The remainder should be always positive. The
division should not be done using built in C operators but by repeated subtraction.
(b) Write a program that reads an integer n and prints out the number of even digits and odd digits in the
number. For example, if n = 8793421 then the output should be Even=3, Odd=4, if n = 1000001 then
Even=5, Odd=2
[15,15=30]
3. Consider the problem of creating change for a certain amount of money by using the minimum number of
coins/notes. So, assuming we have coins/notes of the following denominations1, 2, 5, 10, 20, 50, 100, 200, 500, 2000
(as we do in India) write a program that reads in a positive number as amount and then outputs the minimum
number of notes/coins and their denominations that will make up the amount.
So, if we had to make up the amount 63, we have 63 = 50 + 10 + 2 + 1 and the output should be:
Number: 4
Denominations: 50=1 10=1 2=1 1=1
To make up 3295 we have 3295 = 2000 + 500 + 500 + 200 + 50 + 20 + 20 + 5 so the output should be:
Number=8
Denominations: 2000=1 500=2 200=1 50=1 20=2 5=1
Think about why you believe your program uses the minimum number of notes/coins. [20]