Printing number of zeros the user asks for

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • astrickler15
    New Member
    • Oct 2016
    • 1

    Printing number of zeros the user asks for

    I am having trouble with making my program print the number of zeros the user inputs. My program prompts the user to input a number, then it prints out zeros based on the number they input. For example, if the user types in 5, my program prints out "5 zeros: 00000." We are working on do while loops if that helps any. My program as of now compiles and works correctly other than the fact that it is only printing 1 zero no matter what they input.
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    astrickler15,

    We can't offer any suggestions at this point without seeing what you've written.

    Will you please show us a copy of your code. Please use code blocks to make it easily readable.

    Thanks,
    Oralloy

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Use a while loop. Have the loop print a 0. If the user enters 5, cycle the loop 5 times.

      Code:
      while (n)
      {
        printf('0');  
        --n;
      }

      Comment

      Working...