C Language "M shape Pattern using for loop" program with output

#include <stdio.h> int main() { int i, j, n; printf("Enter the number of rows: "); scanf("%d", &n); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (j == 1 || j == n || (i == j && i <= n / 2) || (i + j == n + 1 && i <= n / 2)) printf("*"); else printf(" "); } printf("\n"); } return 0; }


Output

Enter the number of rows: 7 * * ** ** * * * * * * * * * * * * * * *

Comments

Popular posts from this blog

Video Formats

Where video editing is used

File saving and folder management