Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- chessboard_pattern_v1.c
- https://www.facebook.com/groups/3092811364081112/?multi_permalinks=7271679206194286&ref=share
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- void print_chessboard_pattern(int n){
- for(int a=1; a<=n; a++)
- if(a%2!=0)
- for(int i=1; i<=n; i++){
- for(int j=1; j<=n; j++)
- if(j%2!=0)
- for(int k=1; k<=n; k++)
- printf(" ");
- else
- for(int k=1; k<=n; k++)
- printf("* ");
- printf("\n");
- }
- else
- for(int i=1; i<=n; i++){
- for(int j=1; j<=n; j++)
- if(j%2!=0)
- for(int k=1; k<=n; k++)
- printf("* ");
- else
- for(int k=1; k<=n; k++)
- printf(" ");
- printf("\n");
- }
- }
- int main(void){
- int n=6;
- for(int i=2; i<=n; i++){
- printf("\n n = %d \n\n",i);
- print_chessboard_pattern(i);
- printf("\n\n");
- }
- return 0;
- } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement