-1

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.

#include<stdio.h>
#include<conio.h>
int main()
{
int integer, counter, counter2;
counter = 0;
counter2 = 0;
printf("Enter a number: ");
scanf("%d",&integer);
do {
    printf("*");
    integer++;
    }while(counter<0);

do {
    printf("*");        
    counter++;

    }while(counter<integer);

getch();
return 0;
}

Edited by pritaeas: Fixed markdown.

3
Contributors
3
Replies
42
Views
3 Years
Discussion Span
Last Post by marc.orocay
0
  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 by DeanMSands3

0

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 by Lucaci Andrew

-1

@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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.