C Program to print the below(Diamond) pattern in the console
#include<stdio.h> #include<stdlib.h> void main() { int n = 5; int k = n+(n-1); for (int row = 0; row < k; ++row) { if (row <= (n-1)) { for (int col = 0 ; col < k; ++col) { int tmpCol = ((n-row)-1); int tmpCol1 = ((n+row)-1); if ((col == tmpCol) || (col == tmpCol1)) { printf("* "); } else { printf(" "); } } }else { for (int col = 0 ; col < k; ++col) { int tmpCol = row%n+1; int tmpCol1 = (k-2)-row%n; if ((col == tmpCol) || (col == tmpCol1)) { printf("* "); } else { printf(" "); } } } printf("\n"); } }