C program pattern
#include <stdio.h>
int main() { int a, b; int n = 7; // Height of the J pattern
for (a = 0; a < n; a++) { for (b = 0; b < n; b++) { // Print the vertical part of J if (b == n / 2 && a != 0 || (a == n - 1 && b <= n / 2) || (a == n - 2 && b == 0)) printf("*"); else printf(" "); } printf("\n"); }
return 0;}
Header File
#include <stdio.h>
- Standard I/O library to use the printf function for output.
