can someone help me, I need a program like this but it must not use for loop.
or can someone revise it using do loop? I need it badly

here is the code:
{


int n, i, j;

do{
    printf("Enter a positive int n: ");
    scanf("%d",&n);

   } while (n < 0); 




  do{


    for (i = 1; i <= n; i++)
    {
     for (j = 1; j <= i; j++)
         printf("*");
         printf("\n");                

    }


 } while (i <= n);        
getch();



}

No one is going to do your work for you. There is little difference in a do-while loop compared to a for loop. Yopu just have to make your own counter and take care of it with a do while loop versus a for loop. Here is how you can chnage a for loop to a do-while loop:

for (int i = 0 /*variables*/; i < 10 /* condition */; i++ /*increment section */)
    {
        //do stuff
    }

    // becomes

    int i = 0; // variable section
    do
    {
        //do stuff
        i++; // dont forget to increment the counter.  increment section
    } while (i < 10) // condtion 

Now that you have that you should be able to do it with a for loop and then once that is working you can convert the for loop to a do-while loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.