Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- simple star-o pattern v1 .c
- oooooooooo
- *********
- oooooooo
- *******
- oooooo
- *****
- oooo
- ***
- oo
- *
- */
- #include "stdio.h"
- int main(void)
- {
- /*
- i for loop counter,
- r row,
- nr number_of_rows,
- no number_of_o,
- na number_of_*
- */
- int i, r, nr, no, na;
- printf("\n Enter number of rows, nr = ");
- scanf("%d", &nr); // try 10
- no = nr; // initial value
- na = nr-1; // initial value
- printf("\n"); // print new row
- for (r=0; r<nr/2; r++) // repeat nr/2 times
- { // print two rows at once, that is why r<nr/2
- for (i=0; i<no; i++) // print first row with "o", no times
- printf("o");
- printf("\n"); // print new row
- for (i=0; i<na; i++) // print second row with "*", na times
- printf("*");
- printf("\n"); // print new row
- no = no-2; // new numbers of "o" for next first row repeat
- na = na-2; // new numbers of "*" for next second row repeat
- }
- printf("\n"); // print new row
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement