Print the following pattern with c language
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,j;
printf("\t
enter value of n=");
printf("\n\n");
for(i=0;i<n;i++)
{
for(j=0;j<2*n-1;j++)
{
if(j==(n-1)-i||j==(n-1)+i||i==n/2&&(j>=n/2&&j<=(n-1)+(n/2)))
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
No comments:
Post a Comment