-
for loop
Code:
i made a source code lwhich has an output like this:
*
**
***
****
*****
and a source code like this
int i,j;
for(i=1;i<=5;i++){
for(j=1;j<=6-1;j++){
puts('*');
}
printf("\n");
}
return 0;
}
how can i turn the five(5)columns on the right side
and the opposite, the single * is at the bottom and a source code of * that forms an inverted triangle
thank you
-
Run the loop once forwards, then run it again backwards.
-
so how is that?should i change the < to >?
or the initial value of 'i' will be equal to to 5?
-
Quote:
Originally Posted by
ricnoah
Code:
i made a source code lwhich has an output like this:
*
**
***
****
*****
and a source code like this
int i,j;
for(i=1;i<=5;i++){
for(j=1;j<=6-1;j++){
puts('*');
}
printf("\n");
}
return 0;
}
how can i turn the five(5)columns on the right side
and the opposite, the single * is at the bottom and a source code of * that forms an inverted triangle
thank you
That code will NOT produce the output you've indicated, it won't even compile cleanly (puts does not accept a single character argument). And don't put code tags around your entire post, just the code parts. If you were to understand how correct code to produce the first part worked then it should be easy enough to figure out how to do what you're asking.