write a c++ program that will be used in a grocery store.the program reads a whole change amount in dirhams and prints how many 500 dirham bills,200 dirham bills,100 dirham bills ,50 dirham bills ,20 dirham bills ,10 dirham bills 5 dirham bills ,and 1 dirhams coins should the cashier return to the customer.
for example,if the cashier enters 2789 dirhams,the program should print:
amount entered:2789 Dirhams
5-500 dirham bills
1-200 dirham bills
1-50 dirham bills
1-20 dirham bills
1-10 dirham bills
1-5 dirham bills
4-1 dirham coins
the program should read many positive values and calculate the change for each one stop the program when you enter a 0 or a negative value
the program should use at least one function,one for loop,and one sentinel-controlled while loop.

Recommended Answers

All 4 Replies

Greetings sarahrasheed,

This type of program isn't very difficult to write. Is there any part of this code you are struggling on?

- Stack Overflow

im still biggener and still learning C++...so i need ur help with that plz


It is DaniWeb policy to assist you in writing your code, not to do it for you. You mentioned that you are learning C++. What have you learned so far?

We need you to provide code, so that we can help you tweak it.


commented: Great answer! +3

Hi sararasheed ; (as sararasheed is a begginer so we should give him/her code)

Here is the programme u asked for. plz check it and let me now if it has some problems...


# include<iostream.h>

void result(int,int []);

void main()
int t=0;
int array[7]={0};

cout<<"Enter Total Amount\n";


    cout<<"Amount entered: "<<t<<" Dirhams\n";
    cout<<array[0]<<"-500 dirham bills \n";
    cout<<array[1]<<"-200 dirham bills \n";
    cout<<array[2]<<"-50 dirham bills \n";
    cout<<array[3]<<"-20 dirham bills \n";
    cout<<array[4]<<"-10 dirham bills \n";
    cout<<array[5]<<"-5 dirham bills \n";
    cout<<array[6]<<"-1 dirham coins\n"<<endl<<endl;

    cout<<"Again Enter Totak Amount\n";
    cout<<"Thanks for using this programme\n";


void result(int t,int array[])

    int temp=t;

    int t_array[7]={500,200,50,20,10,5,1};

    for(int i=0;i<7;i++)
commented: Direct violation of DaniWeb Policy, despite my comments in the forum. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.