Originally Posted by
ksample23
Lets say the user enters the number 5....
How do output 5 *'s on the screen? (or 5 spaces)?
By using loops whose loop-counter corresponds to your input. As said above, if you use a loop to print the characters you will print 5 characters if the user's input was 5, and 10 accordingly if the user input was 10. E.g.
Code:
int i;
for (i = 0; i < <user_input>; i++)
{
print the character;
}
Originally Posted by
ksample23
Also, is possible to use if or while loops for this instead of for loops?
you could transform each for loop into a while loop. But, I don't really know what you mean by IF. IF isn't a loop statement ...
- Andi -