anyone know how to print this output ????
using three for loop

5 Years
Discussion Span
Last Post by Tajinderpal

Show your approach to the problem. We can't provide you the code directly, according to rules. Post your approach, we'll ammend the code and help you out. :)


here's a pseudocode to give you a hint:

    x = 5
    while the value of x is not equal to 0 
        y = 5
        while the value of y is not equal to 0 
        if the value of y less than or equal to x
            print an asterisk
            print a space
            decrement y;
        end while
        decrement x
        print a newline
    end while

To print that output you have to use three loops.
1.) one is the outer loop used to present the rows.
2.) second is a inner loop which will print spaces.
3.) third is again a inner loop which will be placed just after secong loop and will print "*".

so here is the layout-

for(how many rows you want)
    for(print a triangle of " " (spaces)
    for(print a reverse triangle of "*")
Votes + Comments
Isn't that basically what ZEROLIKEN said?
for(int i=5;i>0;i--)
     for(int j=1;j<i;j++)
         printf("* ");
Votes + Comments
Hope you get a good grade inon93's class
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.