Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6710643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:02:46+00:00 2026-05-26T08:02:46+00:00

I have got an assignment in which I should program a simple teller machine

  • 0

I have got an assignment in which I should program a simple teller machine which takes an amount of 10 dollar bills and exchanges these to 100, 50, 20 and 10 dollar bills. The least amount of bills should be returned.

The assignment focuses a lot on pointers and I am starting to doubt if what I do is good programming style because I believe I take the pointer to a pointer (e.g. &*balance)

Is this a good way to do it or should I rewrite it?

This is my my main:

int main(void) {
    int amount = 0; // Amount of 10 dollar bills
    int balance = 0; // Total balance (in dollars)
    int hundred = 0, fifty = 0, twenty = 0, ten = 0; // Amount of bills calculated

    // Set number of 10 dollar bills
    printf("Enter amount of 10 dollar bills: ");
    scanf("%d", &amount);

    // Set balance to user's 10 dollar bills
    valueOfBills(&balance, &amount, BILL_VALUE_TEN);

    // Calculate amount of bills for the different types
    amountOfBills(&balance, &hundred, &fifty, &twenty, &ten);
}

In my main I call amountOfBills() which is a procedure which counts how many of each bill to return:

void amountOfBills(int *balance, int *hundred, int *fifty, int *twenty, int *ten) {
    /* To end up with the least amount of bills, we will start with bills with the largest value */

    // Calculate amount of 100 dollar bills
    amountOfBillsForBillValue(&*hundred, &*balance, BILL_VALUE_HUNDRED);

    // Calculate amount of 50 dollar bills
    amountOfBillsForBillValue(&*fifty, &*balance, BILL_VALUE_FIFTY);

    // Calculate amount of 20 dollar bills
    amountOfBillsForBillValue(&*twenty, &*balance, BILL_VALUE_TWENTY);

    // Calculate amount of 10 dollar bills
    amountOfBillsForBillValue(&*ten, &*balance, BILL_VALUE_TEN);
}

In amountOfBills() I call amountOfBillsForBillValue() which counts how many of a specific bill (e.g. 100 dollar bills) to return:

void amountOfBillsForBillValue(int *storeAmount, int *balance, int billValue) {
    /* We don't want to do anything if the balance is 0
       therefore we will just return to avoid any calculations */
    if (balance == 0) return;

    // Calculate amount
    *storeAmount = *balance / billValue;

    // Set balance
    *balance %= billValue;
}

In amountOfBills() I use &*balance. Should I do this another way or is it fine to do so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:02:46+00:00Added an answer on May 26, 2026 at 8:02 am

    &* cancels each other. Just balance will do you the same service as &*balance and with two fewer characters. On the other hand if you just want to remember that it’s poiner, using the &* does not do any harm and the compiler will know well enough that it’s a noop.

    There is however another thing that is definitely not good style. The way you use explicit parameters for the various type of notes. If when you finish this somebody comes and tells you “we have added five hundred dollar bills and we won’t bother filling in twenty dollar bills”, you’ll have to modify everything. You should generalize instead. Have array of values and array of counts…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got an assignment in which I have to implement a AS3 wrapper
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC
I have got some code to load an assembly and get all types, which
I have got a assignment to develop a IPhone application in HTML 5 &
I have an assignment and i got a library including an interface class. [InfoItem]
So I have this University assignment in which I have to create a trigger
ive got an assignment which requires me to set default language to a win
I've got some code I have a :notice, which is only showing up selectively.
I have got an assignment in VBA where I have to convert an existing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.