Program to find the count of coins of each type from the given ratio | C ++ implementation of above approach ; function to calculate coin . ; Converting each of them in rupees . As we are given totalRupees = 1800 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int coin ( int totalRupees , int X , int Y , int Z ) { float one = 0 , fifty = 0 , twentyfive = 0 , result = 0 , total = 0 ; one = X * 1 ; fifty = ( ( Y * 1 ) / 2.0 ) ; twentyfive = ( ( Z * 1 ) / 4.0 ) ; total = one + fifty + twentyfive ; result = ( ( totalRupees ) / total ) ; return result ; } int main ( ) { int totalRupees = 1800 ; int X = 1 , Y = 2 , Z = 4 ; int Rupees = coin ( totalRupees , X , Y , Z ) ; cout << "1 ▁ rupess ▁ coins ▁ = ▁ " << Rupees * 1 << endl ; cout << "50 ▁ paisa ▁ coins ▁ = ▁ " << Rupees * 2 << endl ; cout << "25 ▁ paisa ▁ coins ▁ = ▁ " << Rupees * 4 << endl ; return 0 ; }