Knowee
Questions
Features
Study Tools

Write a C program, which reads in the amount and prints the number of notes/coins of each denomination. Start with the highest denomination of Indian currency. 23761 x 20001 x 2001 x 1001 x 501 x 201 x 51 x 1

Question

Write a C program, which reads in the amount and prints the number of notes/coins of each denomination. Start with the highest denomination of Indian currency. 23761 x 20001 x 2001 x 1001 x 501 x 201 x 51 x 1

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple C program that reads an amount and prints the number of notes/coins of each denomination in Indian currency. The denominations are 2000, 500, 200, 100, 50, 20, 10, 5, 2, and 1.

#include <stdio.h>

int main() {
    int amount;
    int denominations[10] = {2000, 500, 200, 100, 50, 20, 10, 5, 2, 1};
    int notes[10] = {0};

    printf("Enter the amount: ");
    scanf("%d", &amount);

    for(int i = 0; i < 10; i++) {
        if(amount >= denominations[i]) {
            notes[i] = amount / denominations[i];
            amount = amount - notes[i] * denominations[i];
        }
    }

    printf("\nNumber of notes/coins of each denomination:\n");
    for(int i = 0; i < 10; i++) {
        if(notes[i] != 0) {
            printf("%d x %d\n", denominations[i], notes[i]);
        }
    }

    return 0;
}

This program works by dividing the amount by each denomination in descending order, storing the quotient (number of notes/coins) and updating the amount to the remainder. It then prints the number of notes/coins for each denomination.

This problem has been solved

Similar Questions

Armstrong was one of the greatest scientist.The Indian Science Council decided to design an Memorable Coin with many numbers printed on it in memory of Great Armstrong.But ISC is looking for a criteria to decide which numbers need to be printed on the Prestigious Gold Coin.There was a suggestion given by the Members of Indian Science Council.If the sum of the cube of each number is again equal to the number then that particular number can be added into the coin.Kindly help the Indian Science Council to implement the task by writing a simple programming logic.Constraints:1≤number≤1000Input format:Only line of input has a single integer representing the number. Output format:In the only line of output print as “Part of Memorable Coin” or “Not a Part of Memorable Coin” based on the condition.

Mary is a cashier at a store and needs a program to help her break down amounts of money into specific denominations. Depending on the customer's preference, she needs to provide either the number of notes or coins needed to make up a given amount. Write a program that takes the amount of money and the preferred mode as input, and outputs the number of each denomination required to make up that amount.Company Tags: Adobe, InfosysInput format :The first line of input contains a double value, representing the amount of money.The second line contains a string, either 'notes' or 'coins', indicating the preferred mode of denomination.Output format :If the mode is 'notes', print the number of 500, 100, 50, and 10 denomination notes required, each on a new line.If the mode is 'coins', print the number of 25, 10, 5, and 1 cent coins required, each on a new line.If the mode is invalid, print "Invalid mode"Refer to the sample output formatting specifications.Code constraints :10.0 ≤ amount ≤ 5000.0Sample test cases :Input 1 :35.60coinsOutput 1 :25 cents: 14210 cents: 15 cents: 01 cent: 0Input 2 :2250.29notesOutput 2 :500: 4100: 250: 110: 0Input 3 :3000.50CurrencyOutput 3 :Invalid mode

Single File Programming QuestionProblem StatementPranav is playing a coin game with his friends. Create a simple program to assist Pranav in converting a given amount of cash into the minimum number of coins. Prompt Pranav to input the cash amount and utilize assignment operators to calculate and display the minimum number of coins needed for denominations of 100, 50, 10, 5, 2, and 1. Assume these denominations as coins with values of 100, 50, 10, 5, 2, and 1, respectively.Note:Give the input greater than 100.Input format :The input is a single integer c representing the amount of cash.Output format :The output displays the minimum number of rupee notes for denominations of 100, 50, 10, 5, 2, and 1.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:100 ≤ c ≤ 10000Do not use any looping structures.Sample test cases :Input 1 :100Output 1 :1Input 2 :589Output 2 :12Input 3 :10000Output 3 :100Code Size : 1024 kbNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.

Write a program that prints the minimum number of coins to make change for an amount of money.Usage: ./change centswhere cents is the amount of cents you need to give backif the number of arguments passed to your program is not exactly 1, print Error, followed by a new line, and return 1you should use atoi to parse the parameter passed to your programIf the number passed as the argument is negative, print 0, followed by a new lineYou can use an unlimited number of coins of values 25, 10, 5, 2, and 1 cent

Prompt Pranav to input the cash amount and utilize assignment operators to calculate and display the minimum number of coins needed for denominations of 100, 50, 10, 5, 2, and 1. Assume these denominations as coins with values of 100, 50, 10, 5, 2, and 1, respectively.

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.