C Program
C program to Print B star pattern Asterisks pattern
Example:-
#include <stdio.h>
int main() {
int a, b;
int rows = 7;
for (a= 0; a < rows; a++) {
for (b= 0; b < 5; b++) {
if (b == 0 ||
(a == 0 && b < 4) ||
(a == rows / 2 && b < 4) ||
(a == rows - 1 && b < 4) ||
(b == 4 && a!= 0 && a != rows / 2 && a != rows - 1)) {
printf("*");
} else {
printf(" ");
}
}
printf("\n");
}
return 0;
}
No comments:
Post a Comment