Hello friends today i am trying to print the following pattern,just read the code if you think that there is better solution of this pattern than share with me....
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,l,m;
clrscr();
m=7;
for(i=1;i<=2;i++)
{
for(j=1;j<=i;j++)
{
printf(" *");
for(k=1;k<i;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
{
printf("*");
for(k=1;k<i;k++)
printf(" ");
}
printf("\n");
l=i;
m=m-2;
printf(" ");
for(j=1;j<=l;j++)
{
printf(" *");
for(k=1;k<l;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=l;j++)
{
printf(" *");
for(k=1;k<l;k++)
printf(" ");
}
printf("\n");
m=m-2;
}
printf(" *");
printf(" ");
printf(" *");
printf(" ");
printf(" *");
printf(" ");
printf("*");
printf(" ");
printf(" *");
printf("\n");
m=1;
for(i=2;i>=1;i--)
{
printf(" ");
for(j=1;j<=i;j++)
{
printf(" *");
for(k=1;k<i;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
{
printf(" *");
for(k=1;k<i;k++)
printf(" ");
}
printf("\n");
l=i;
m=m+2;
for(j=1;j<=l;j++)
{
printf(" *");
for(k=1;k<l;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=l;j++)
{
printf("*");
for(k=1;k<l;k++)
printf(" ");
}
printf("\n");
m=m+2;
}
getch();
return(0);
}
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,l,m;
clrscr();
m=7;
for(i=1;i<=2;i++)
{
for(j=1;j<=i;j++)
{
printf(" *");
for(k=1;k<i;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
{
printf("*");
for(k=1;k<i;k++)
printf(" ");
}
printf("\n");
l=i;
m=m-2;
printf(" ");
for(j=1;j<=l;j++)
{
printf(" *");
for(k=1;k<l;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=l;j++)
{
printf(" *");
for(k=1;k<l;k++)
printf(" ");
}
printf("\n");
m=m-2;
}
printf(" *");
printf(" ");
printf(" *");
printf(" ");
printf(" *");
printf(" ");
printf("*");
printf(" ");
printf(" *");
printf("\n");
m=1;
for(i=2;i>=1;i--)
{
printf(" ");
for(j=1;j<=i;j++)
{
printf(" *");
for(k=1;k<i;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
{
printf(" *");
for(k=1;k<i;k++)
printf(" ");
}
printf("\n");
l=i;
m=m+2;
for(j=1;j<=l;j++)
{
printf(" *");
for(k=1;k<l;k++)
printf(" ");
}
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=l;j++)
{
printf("*");
for(k=1;k<l;k++)
printf(" ");
}
printf("\n");
m=m+2;
}
getch();
return(0);
}
THAKNING YOU FRIENDS.....
No comments:
Post a Comment
Please Give Me Your Views