4
1 2 5 6 3 4 7 10 11 8 9 12 13 14 15 16 (numbers filled row-wise, then printed diagonally in zig-zag)
void pattern_q13_zigzag() {
int rows = 3;
int cols = 20;
for(int i = 1; i <= rows; i++) {
for(int j = 1; j <= cols; j++) {
if((i + j) % 4 == 0 || (i == 2 && j % 4 == 0)) {
cout << "*";
} else {
cout << " ";
}
}
cout << endl;
}
}
void pattern_q13_zigzag() {
int rows = 3;
int cols = 20;
for(int i = 1; i <= rows; i++) {
for(int j = 1; j <= cols; j++) {
if((i + j) % 4 == 0 || (i == 2 && j % 4 == 0)) {
cout << "*";
} else {
cout << " ";
}
}
cout << endl;
}
}