Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- simple star-o pattern v2 .c
- h = 10
- i j=h-i
- 0 10
- 1 9
- 2 8
- 3 7
- 4 6
- 5 5
- 6 4
- 7 3
- 8 2
- 9 1
- */
- #include<stdio.h>
- int main(void)
- {
- /*
- i number of current row
- j number of chars in current row
- h number of rows of whole tirangle
- */
- int i,j,h;
- printf("Enter the height of the triangle : ");
- scanf("%d",&h);
- printf("\n");
- for(i=0;i<h;i++) // repeat loop for rows of triangle, h times
- {
- for(j=0;j<h-i;j++) // repeat loop for chars in single row, h-i times
- {
- if(i%2==0) // if row is even
- printf("O"); // print "O"
- else // if row is odd
- printf("*"); // print "*"
- }
- printf("\n"); // go to next row
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement