Someone help me creating a this program. Well, I need a program that makes a triangle out of asterisk but it doesnt use "for" loop it only requires "do-while" loop. Actually I tried making one but it doesn't look like a triangle instead it jsut display a line of asterisk.

int main()
int integer, counter, counter2;
counter = 0;
counter2 = 0;
printf("Enter a number: ");
do {

do {


return 0;

Edited 2 Years Ago by pritaeas: Fixed markdown.

  1. One do loop needs to enclose the other.
  2. The variable in the inner loop (perhaps counter) needs to reset to zero everytime the outer loop starts.
  3. After the inner loop, print a "\n" (This starts a new line.)
  4. The inner loop variable (counter)needs to be less than the outer loop variable (counter2) which in turn needs to be less than the input variable (integer).
  5. This is much easier to do with for loops, but I'm guessing you're stuck with do-while.

Edited 2 Years Ago by DeanMSands3

This was already tackled at this post, see the doing, and try to apply to your need:
Click Here
Search the forums first, you'll be amazed of what you can find. ;)

Edited 2 Years Ago by Lucaci Andrew

@DeanMSands Yes sir indeed, I still can't use the for loop cause right now I am still tackling about do-while loop. Can you give me a code sir?

This article has been dead for over six months. Start a new discussion instead.