lucproblem001.c (1069B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Consider a currency system in which there are notes of six denominations, 8 namely, Rs. 1, Rs. 2, rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum 9 of Rs. N is entered through the keyboard, Write a program to compute 10 the smallest number of notes that will combine to give Rs. N. */ 11 /* Let Us C, Chap - 2, Page - 22, Problem 2.3 */ 12 13 #include <stdio.h> 14 int main() 15 { 16 int n, nonotes, temp; 17 printf("Enter the amount : "); 18 scanf("%d", &n); 19 if (n < 1) 20 { 21 printf("\nAmount should be a positive integer."); 22 return 1; 23 } 24 temp = n; 25 nonotes = n / 100; 26 n = n % 100; 27 nonotes = nonotes + (n / 50); 28 n = n % 50; 29 nonotes = nonotes + (n / 10); 30 n = n % 10; 31 nonotes = nonotes + (n / 5); 32 n = n % 5; 33 nonotes = nonotes + (n / 2); 34 n = n % 2; 35 nonotes = nonotes + n; 36 printf("\nthe smallest number of notes that will combine to give Rs. %d : %d", temp, nonotes); 37 return 0; 38 }