HI i made this program for odd inputs if press 5 then
*****
* *
*****
* *
*****
but not showing the correct answer.
write a right code if u can plz thanks alott.
#include <stdio.h>
int main()
{
int num, i;
printf("press any odd num");
scanf("%d", &num);
if (num % 2 == 0)
printf("use odd number thanks");
else
{
for (i = 1; i <= num; i++)
{
if (i % 2 == 1) // If position is odd
{
for (int i = 1; i <= num; i++)
printf("*");
printf("\n"); // Print a newline for good looking output
}
else
{
printf("*");
for (int i = 2; i <= num - 1;
printf(" ");
printf("*\n");
}
}
}
return 0;
}