Hey everyone I am very new at C++! I am in into to C++ now and I found a program in my book I don't quite understand. If anyone could point me in the right direction I would really appreciate it.
Here's the problem:
Write a change making program. Prompt the user for an amount of change,
then determine how many quarters, dimes, nickels and pennies that amount
would make. (I think using the modulus operator is the way to go but I have no clue how to properly use it.)
#include <iostream>
usingnamespace std;
int main(){
int cent;
int quarter = 25;
int dime = 10;
int nickel = 5;
int penny = 1;
cout << "Enter an amount in cents: ";
cin >> cent;
cout << "The amount you entered is: " << cent << " cents\n";
cout << endl;
//I know there are not right but it's all I could come up with atm
if (cent % quarter)
cout << "Quarters: " << cent << endl;
if (cent % dime)
cout << "Dimes: " << cent << endl;
if (cent % nickel)
cout << "Nickels: " << cent << endl;
if (cent % penny)
cout << "Pennies: " << cent << endl;
system("pause");
return 0;
}