zizag c
Sure! Here is an example of a zigzag pattern in C:
#include <stdio.h>
int main() {
int rows, cols;
printf("Enter the number of rows: ");
scanf("%d", &rows);
printf("Enter the number of columns: ");
scanf("%d", &cols);
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= cols; j++) {
if (i % 2 == 0) {
printf("* ");
} else {
printf(" *");
}
}
printf("\n");
}
return 0;
}
This code prompts the user to enter the number of rows and columns for the zigzag pattern. It then uses nested loops to print the pattern, alternating between printing a '' and a space. The pattern is printed row by row, with even rows having the '' before the space and odd rows having the space before the '*'.