Search:

Type: Posts; User: KevinWorkman

Search: Search took 0.27 seconds.

  1. Re: Improving the code to produce the same program

    Well, you're only using the for loop to print out multiple copies of the same value, which is fine if that's what you want to print out.

    Why are you printing out the result of the modulus in that...
  2. Re: Improving the code to produce the same program

    Hint: What happens when you divide 45 by 20 and cast it to an int? How many 20s do you want to give out? How much do you have left over? What happens when you use the modulus operator?
  3. Re: Improving the code to produce the same program

    You could accomplish your goal with basic division and modulus instead of a series of while loops. This is a pretty common algorithm.

    As for how you have it, if I request 45, isn't it going to...
  4. Re: Improving the code to produce the same program

    You might want to look into the modulus operator.
Results 1 to 4 of 4