anyone know how to print this output ????
using three for loop
*****
****
***
**
*
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
else
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 "*")
{
}
}
for(int i=5;i>0;i--)
{
for(int j=1;j<i;j++)
{
printf("* ");
}
printf("\n");
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.