C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*Saba looks like code is copied from internet as its contain stray especial character which shows when you copied from any source or ide to sololearn.
For converting into c all are good by syntax you just need to add printf instead of cout */
// CPP program to print diagonal star patterns
#include <stdio.h>
void pattern(int n)
{// Loop denoting rows
for (int i = 0; i < n; i++) {
// Loop denoting columns
for (int j = 0; j < n; j++) {
// Checking boundary conditions and main
// diagonal and secondary diagonal conditions
if (i == 0 || j == 0 || i == j || i == n - 1 || j == n - 1 || i + j == n - 1)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
// Driver code
int main()
{
// n denotes size which should be odd
int n;
scanf("%d", &n);
// Function calling
pattern(n);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run