bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / lucproblem001.c

lucproblem001.c (933B)


      1 /* Consider a currency system in which there are notes of six denominations,
      2 namely, Rs. 1, Rs. 2, rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum
      3 of Rs. N is entered through the keyboard, Write a program to compute
      4 the smallest number of notes that will combine to give Rs. N. */
      5 /* Let Us C, Chap - 2, Page - 22, Problem 2.3 */
      6 
      7 #include <stdio.h>
      8 int main()
      9 {
     10     int n, nonotes, temp;
     11     printf("Enter the amount : ");
     12     scanf("%d", &n);
     13     if (n < 1)
     14     {
     15         printf("\nAmount should be a positive integer.");
     16         return 1;
     17     }
     18     temp = n;
     19     nonotes = n / 100;
     20     n = n % 100;
     21     nonotes = nonotes + (n / 50);
     22     n = n % 50;
     23     nonotes = nonotes + (n / 10);
     24     n = n % 10;
     25     nonotes = nonotes + (n / 5);
     26     n = n % 5;
     27     nonotes = nonotes + (n / 2);
     28     n = n % 2;
     29     nonotes = nonotes + n;
     30     printf("\nthe smallest number of notes that will combine to give Rs. %d : %d", temp, nonotes);
     31     return 0;
     32 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror