Answer:
//Here is code in c++.
//including header
#include <bits/stdc++.h>
using namespace std;
//main function
int main() {
//variable to read total cents
int p;
cout<<"Please Enter the total cents:";
// read input from user
cin>>p;
int x=p;
int q=0,d=0,n=0,dd=0;
//calculating dollars
dd=p/100;
p=p%100;
//calculating quarter
q=p/25;
p=p%25;
//calculating dimes
d=p/10;
p=p%10;
//calculating nickle
n=p/5;
p=p%5;
//output
cout<<x<<" cents is "<<dd<<" dollars "<<q<<" quarter, "<<d<<" dimes, "<<n<<" nickle and "<<p<<" pennies"<<endl;
}
Step-by-step explanation:
First read total cents from user.Then find the total dollars when total cents divided by 100.Update the total cent after calculating dollars.then find total quarters when cents divided by 25.After this update the total cents.Similarly find the total dimes ,nickle and pennies.
Output:
Please Enter the total cents:27
27 cents is 0 dollars 1 quarter, 0 dimes, 0 nickle and 2 pennies