You are viewing our Forum Archives. To view or take place in current topics click here.
So ran into a bump any help would be great!!! Basic C
Posted:

So ran into a bump any help would be great!!! Basic CPosted:

dj
  • Administrator
Status: Offline
Joined: Aug 06, 201113Year Member
Posts: 3,081
Reputation Power: 23701
Motto: space
Motto: space
Status: Offline
Joined: Aug 06, 201113Year Member
Posts: 3,081
Reputation Power: 23701
Motto: space
So yesterday had a lab with similar build but instead of getting the total cents by entering different amounts of quarters, dimes, nickels, and pennies then getting a total.
But for some extra credit need to enter a total amount of change (any amount doesn't matter) pretty much a quarter, dime, nickel, and penny counter instead of a total amount calculator. Here's my build but seem to run into trouble were its only dividing up to the quarters then stops at dimes. I know this forum isn't a programming site but just if someone can help on what I missed. Feel its something really dumb.

[ Register or Signin to view external links. ]


Thanks for the help guys

The following 1 user thanked dj for this useful post:

Streamah (06-12-2016)
#2. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
I'd assume this is because the only int you've actually initialized is the first total. The rest aren't initialized so you can't use them in arithmetic operators. I'm not sure if C auto sets the value of allocated ints to 0, that may be your error since the IDE would tell you if it hadn't been initialized. You're getting 0 because 0 divided by anything is 0.

Also, don't surround your int values with brackets - there's no point. Don't use numbers in variable names.
#3. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Also, if you're wanting 'extra credit' - look into the modulus operator, if you know what that does, you'll know what I think you should give a go.

[spoiler]
Will tell you if remainder of 123 / 25 is present, if so.. take it and then divide it by the next smaller money value (dime) and keep doing that until you possibly get to pennies (if it's divisible by 5, you probably won't get to pennies).
[/spoiler]
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.