#include <stdio.h>
#include<conio.h>
int main()
{
int amount;
// taking input
printf("Enter the amount to be withdrawn (in hundreds):
");
scanf("%d",&amount);
//calculations
printf("\n\nRequired notes of Rs. 100 :
%d", amount / 100);
// e.g. if amount entered is 987 then 987 / 100 will answer
9 (because amount is an intiger variable)
printf("\n\nRequired notes of Rs. 50 :
%d", (amount % 100) / 50);
//e.g. 987 % 100 will answer 87 and then 87 / 50 will
answer 1.
printf("\n\nRequired notes of Rs. 10 :
%d", (((amount % 100) % 50) / 10));
printf("\n\nAmount still remaining Rs. : %d", (((amount % 100) % 50) %
10));
getch();
}
Thank you for posting
ReplyDeleteThank you for posting
ReplyDeletewhy are using getch()
ReplyDeleteto get our result on screen
Deleteby this we comand the compiler to print the screen
getch(); command is use to get output on screen, its command is written in header file conio.h, through this we command the compiler to print on screen
Deletehi KHURRAM ALI
Deletebasically getch() is a pre-defined function used to take a character as an input ,but using this function at the end of a program has a different aspect as we use it here to hold the screen till the user presses any key to return to the code screen
Yes you gave the right answer .
DeleteThis is very educational content and written well for a change.650 euros to dollars It's nice to see that some people still understand how to write a quality post!
ReplyDeleteIf you people don't mind is there anyone who can explain this program.
ReplyDeleteAssume amount to be 3287,
Delete1. To obtain number of 100th notes we divide the amount by 100.(i.e 3287/100=>total of 32 notes of 100Rs.
2. To obtain remaining amount i.e 87.Apply % with 100.Since,87 is remainder of (3287/100)
Now,obtain number of 50th notes by dividing remainder(87) with 50
3.To obtain number of 10th notes .Get remaining amount i.e(remainder of 87/50)=>17.
Now,Divide 17 with 10
4.At last, the reamining amount that cannot be further distributed from given denomination with 10,50,100 is given by :
3287 % 100 % 50 %10
87 17 7
Is this Coin Change Problem ?
ReplyDeletei need algorithm in python forcashier has currency notes of denominations Rs.10, Rs. 50 and Rs. 100. If the amount to be
ReplyDeletewithdrawn is input in hundreds, find the total number of notes of each denomination the
cashier will have to give to the withdrawer.
Under the header file we will also use clrscr() {to clear the console screen} along with getch()?
ReplyDelete