Question: Display the following checkerboard pattern with eight printf statements and then display the same pattern with as few printf statements as possible.
![Checkerboard pattern of asterisks](https://cscprogrammingtutorials.com/wp-content/uploads/2016/09/c-checkerboard-pattern-of-asterisks.jpg)
Sample Program Run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include <stdio.h> int main (void) { //Program to display checkerboard pattern of asterisks. //using eight printf statements printf("* * * * * * * *\n"); printf(" * * * * * * * *\n"); printf("* * * * * * * *\n"); printf(" * * * * * * * *\n"); printf("* * * * * * * *\n"); printf(" * * * * * * * *\n"); printf("* * * * * * * *\n"); printf(" * * * * * * * *\n\n\n"); //using as few printf statements as possible printf("* * * * * * * *\n * * * * * * * *\n* * * * * * * *\n * * * * * * * *\n"); printf("* * * * * * * *\n * * * * * * * *\n* * * * * * * *\n * * * * * * * *\n"); return 0; } |
![Checkerboard pattern of asterisks](https://cscprogrammingtutorials.com/wp-content/uploads/2016/09/c-checkerboard-pattern-of-asterisks.jpg)