Look at this Problem:
Please help me, Figure this out using [TURBO C]
Create a program that will let the user input an amount in the form (367). The Program should determine the no. of coins for each dominations : 50,25,10,5,1.
(using Turbo C)
It would be nice to see some code that you have come up with and then we could help guide you. Right now your looking for the solution which defeats the purpose of the exercise.
dnt blame your teacher ,, just search on loops...
Okay what you have to do is first of all divide amount with 50 then remaing amount with 25 again remaing with 10 and so on...
I normally wouldn't do this but since you did attempt to do something and is completely wrong here is a partial code that you can finish. It will compile and run but doesn't do dimes, nickels, or pennies. And it is apparent you are in the beginning of your learning to code, but that is still no excuse. So take what I have done and finish the code and repost so we can see you are on the right track. I don't want you to get frustrated and quit because the more people we can get coding in this world the better.
To everyone else I'm sure you might get upset with me for posting this much code, but this is a simple problem that by helping him now he might become a better coder later.
#include <iostream>
usingnamespace std;
int main()
{
int num;
do
{
cout << "Give me an integer between 100 - 999 : ";
cin >> num;
if(!(num > 100 && num < 999))
cout << "INVALID ENTRY\n";
}while(!(num > 100 && num < 999));
constint HALFDOLLAR = 50;
constint QUARTER = 25;
constint HOWMANYKINDSOFCOINS = 5;
//and so on
int arrayToHoldEachAmountOfChange[HOWMANYKINDSOFCOINS];
string nameOfCoins[HOWMANYKINDSOFCOINS];
arrayToHoldEachAmountOfChange[0] = num / HALFDOLLAR;
num = num % HALFDOLLAR;
nameOfCoins[0] = "HalfDollars";
arrayToHoldEachAmountOfChange[1] = num / QUARTER;
num = num % QUARTER;
nameOfCoins[1] = "Quarters";
//and so on
for(int i = 0; i < HOWMANYKINDSOFCOINS; i ++)
cout << nameOfCoins[i] << " =" << arrayToHoldEachAmountOfChange[i] << endl;
system("pause");
return 0;
}
Edit: I am only on my fourth month of coding Greedy so I'm sure there are many more ways to this. You can also do the arithmetic within a loop structure just the same.
Thank you for this. I owe my life to you. :) Ill promise I will be a better programmer.
About this code,well, I needed to change it to some turbo C "stuffs". But its fine, I'll handle it. Thank you again. Thank you so much.
*bows* *bows*