C

Simplified tutorials to learn the popular basic language C

VB.Net

Learn the basic desktop development application language

CodeIgniter

One of the popular PHP three tier (MVC) framework

C Program to Accept an Amount and Display the Number of Currency Notes

C  C++ Program to convert and display an amount to different currency notes


This C program will accept an amount, and will convert and display that amount as currency notes...






For example:
If amount is: 123
We can write amount 123 as :


=> Number of notes of 100       = 1
     Number of notes of  20        = 2
     Number of notes of  2          = 1
     Number of notes of  1          = 1
     Total number of currency notes = 1 + 2 + 1 +1 = 5



Example 2:

If amount is: 512
We can write amount 143 as :

=> Number of notes of 100       = 5
     Number of notes of  20        = 0
     Number of notes of  10        = 1
     Number of notes of  2          = 1

     Total number of currency notes = 5 + 0 + 1 +1 = 7


#include <stdio.h>

#include <conio.h>

#include <stdio.h>
#include <conio.h>
 void main()  {    int amt,n1,n2,n3,n4,n5,n6,n7,n8,n9,total;    printf("\n Enter the amount :");    scanf("%d",&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 Number of notes of 1000 = %d ",n1);    printf(" \n Number of notes of 500   = %d ",n2);    printf(" \n Number of notes of 100   = %d ",n3);    printf(" \n Number of notes of 50     = %d ",n4);    printf(" \n Number of notes of 20     = %d ",n5);    printf(" \n Number of notes of 10     = %d ",n6);    printf(" \n Number of notes of 5       = %d ",n7);    printf(" \n Number of notes of 2       = %d ",n8);    printf(" \n Number of notes of 1       = %d ",n9);    printf(" \n Total number of currency notes = %d ",total);    getch( ); }

Output

Enter the amount : 1865
Number of notes of 1000 = 1
Number of notes of 500   = 1
Number of notes of 100 = 3
Number of notes of 50 = 1
Number of notes of 20 = 0
Number of notes of 10 = 1
Number of notes of 5 = 1
Number of notes of 2 = 0
Number of notes of 1 = 0
Total number of currency notes = 8

C  C++ Program to convert an amount to different currency notes

You can convert this C program  to C++ program by changing input - output keywords...

No comments:

Post a Comment