Pages

Thursday, 8 November 2012

WAP to accept an amount from the user and display the number of different denominations.

WAP to accept an amount from the user and display the number of different denominations.
INPUT: 1288
OUTPUT: No. of notes of Rs.100 = 12
                No. of notes of Rs.50 = 1
                No. of notes of Rs.20 = 1
                No. of notes of Rs.10 = 1
                No. of notes of Rs.5 = 1
                No. of notes of Rs.2= 1
                No. of notes of Rs.1 = 1
#include <stdio.h>
void main()
{
    int note[]={100,50,20,10,5,2,1};
    int i,n,amt;
    printf("Enter the amount");
    scanf("%d",&amt);
    for(i=0;i<7;i++)
    {
        n=amt/note[i];
        if(n!=0)
        printf("The no. of notes of Rs.%d= %d\n",note[i],n);
        amt=amt%note[i];
    }
}

No comments:

Post a Comment