Computer Science, asked by zeeniagupta3, 11 months ago

There are N student each have 25 paise,50 paise and 1 RS coins.There are three list to store no. of coins of different denomination each person have. You have to calculate amount in RSs and store it into fourth list and find the Range. Range is the difference between minimum and maximum amount each person have,also find the mean and median from fourth list. You are required to take pointer to an array for all the four lists

Answers

Answered by lakshyashukla2001
0

Answer:

// C++ implementation of above approach  

#include <bits/stdc++.h>  

using namespace std;  

// function to calculate coin.  

int coin(int totalRupees, int X, int Y, int Z)  

{  

float one = 0, fifty = 0, twentyfive = 0,  

 result = 0, total = 0;  

// Converting each of them in rupees.  

// As we are given totalRupees = 1800  

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;  

}  

Explanation:

Let the ratio in which 1 Rs, 50 paise and 25 paise coin is divided is 1:2:4

Now,

1 Rs coins in a bag is 1x.

50 paise coins in a bag is 2x.

25 paise coins in a bag is 4x.

Now convert these paise into Rupees.

So,

x coins of 1 Rs each, the total value is x rupees.

2x coins of 50 paise i.e (1 / 2) rupees each, the total value is x rupees.

4x coins of 25 paise i.e (1 / 4) rupees each, the total is x rupees.

Therefore,

3x = 1800

x = 600

1 rupess coins = 600 * 1 = 600

50 paisa coins = 600 * 2 = 1200

25 paisa coins = 600 * 4 = 2400

Similar questions