#include <stdio.h> int main() { int i, j, N; int count; printf("Enter no. Of Rows To Print X Pattern: "); scanf("%d", &N); count = N * 2 - 1; for(i=1; i<=count; i++) { for(j=1; j<=count; j++) { if(j==i || (j==count - i + 1)) { printf("*"); } else { printf(" "); } } printf("\n"); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter