Saturday, September 24, 2011

Program to accept an amount in rupees and display the number of currency notes


#include <stdio.h>
#include<conio.h>
 void main()
        {
            int amt,t,n1,n2,n3,n4,n5,n6,n7,n8,n9,total;
            printf("\n Enter the amount");
            scanf("%d",&amt);
            t=amt;
            n1=amt/1000;
           amt=amt%1000;
           n2=amt/500;
           amt=amt%500;
           n3=amt/100;
           amt=amt%100;
           n4=amt/50;
           amt=amt%50;
           n5=amt/20;
           amt=amt%20;
           n6=amt/10;
           amt=amt%10;
           n7=amt/5;
           amt=amt%5;
           n8=amt/2;
          n9=amt%2;

          total=n1+n2+n3+n4+n5+n6+n7+n8+n9;
          printf("\n 1000 rupees notes %d ",n1);
          printf(" \t500 rupees notes %d ",n2);
          printf(" \n100 rupees notes %d ",n3);
          printf(" \t50 rupees notes %d ",n4);
          printf(" \n20 rupees notes %d ",n5);
          printf(" \t10 rupees notes %d ",n6);
          printf(" \n5 rupees notes %d  ",n7);
          printf(" \t2 rupees notes %d ",n8);
          printf(" \n1 rupees notes %d ",n9);
          printf(" \tTotal notes %d ",total);
           getch();
    }
OUTPUT
Enter the amount 1685
1000 rupees notes 1    500 rupees notes 1
100 rupees notes 1     50 rupees notes   1
20 rupees notes 1      10 rupees notes 1
5 rupees notes 1         2 rupees notes 0
1 rupees notes 0         Total notes  7

0 comments:

Post a Comment