Q4 Consider a currency system in which there are notes of seven denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum of Rs. N is entered through the keyboard, write a program to computer the smallest number of notes that will combine to given Rs. N.

Q4. Consider a currency system in which there are notes of seven denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum of Rs. N is entered through the keyboard, write a program to computer the smallest number of notes that will combine to given Rs. N.

Program: 63

Consider a currency system in which there are notes of seven denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. If a sum of Rs. N is entered through the keyboard, write a program to computer the smallest number of notes that will combine to given Rs. N.

#include<stdio.h>
#include<conio.h>
int main()
{
    int rs=0, one=0, two=0, five=0, ten=0, fifty=0, hundred=0;

    //input total number of rupees from user
    printf("Enter the sum of rupees: ");
    scanf("%d", &rs);

    //main functionality
    if(rs>=100)
    {
        hundred = rs/100;
        rs = rs%100;
    }

    if(rs>=50)
    {
        fifty = rs/50;
        rs = rs%50;
    }

    if(rs>=10)
    {
        ten = rs/10;
        rs = rs%10;
    }
    if(rs>=5)
    {
        five = rs/5;
        rs = rs%5;
    }
    if(rs>=2)
    {
        two = rs/2;
        rs = rs%2;
    }
    if(rs>=1)
    {
        one = rs;
    }

    //display note's quantity

    printf(" Rs 100 = %d\n Rs 50 = %d\n Rs 10 = %d\n Rs 5 = %d\n Rs 2 = %d\n Rs 1 = %d", hundred, fifty, ten, five, two, one);
    return 0;
}

Output:

Enter the sum of rupees: 1221
 Rs 100 = 12
 Rs 50 = 0
 Rs 10 = 2
 Rs 5 = 0
 Rs 2 = 0
 Rs 1 = 1

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.