By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

Printing number of zeros the user asks for

P: 1
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.
Oct 3 '16 #1
Share this Question
Share on Google+
2 Replies


Oralloy
Expert 100+
P: 983
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
Oct 3 '16 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Use a while loop. Have the loop print a 0. If the user enters 5, cycle the loop 5 times.

Expand|Select|Wrap|Line Numbers
  1. while (n)
  2. {
  3.   printf('0');  
  4.   --n;
  5. }
Oct 3 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.