Write a program which accepts amount as integer and display total number of Notes of Rs. 500, 100, 50, 20, 10, 5 and 1. For example, when user enter a number, 575, the results would be like this... 500: 1 100: 0 50: 1 20: 1 10: 0 5: 1 1: 0 Test Case 1 Input (stdin) 2345 Expected Output Rs.500:4 Rs.100:3 Rs.50:0 Rs.20:2 Rs.10:0 Rs.5:1 Re.1:0 Test Case 2 Input (stdin) 100 Expected Output Rs.500:0 Rs.100:1 Rs.50:0 Rs.20:0 Rs.10:0 Rs.5:0 Re.1:0
#include<iostream>
using namespace std;
int main()
{
int amount;
int note1, note5, note10, note20, note50, note100, note500;
note1 = note5 = note10 = note20 = note50 = note100 = note500 = 0;
cin >> amount;
if(amount >= 500)
{
note500=amount/500;
amount -= note500 * 500;
}
if(amount >= 100)
{
note100 = amount/100;
amount -= note100 * 100;
}
if(amount >= 50)
{
note50 = amount/50;
amount -= note50 * 50;
}
if(amount >= 20)
{
note20 = amount/20;
amount -= note20 * 20;
}
if(amount >= 10)
{
note10 = amount/10;
amount -= note10 * 10;
}
if(amount >= 5)
{
note5 = amount/5;
amount -= note5 * 5;
}
if(amount >= 1)
{
note1 = amount;
}
cout << "Rs.500:" << note500 <<endl;
cout << "Rs.100:" << note100 <<endl;
cout << "Rs.50:" << note50 <<endl;
cout << "Rs.20:" << note20 <<endl;
cout << "Rs.10:" << note10 <<endl;
cout << "Rs.5:" << note5 <<endl;
cout << "Re.1:" << note1 <<endl;
return 0;
}