Hello friends if you want to print the following pattern than see the code,i know this code is little bit long but it is very simple......
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,m;
clrscr();
m=3;
for(i=1;i<=7;i=i+2)
{
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
m--;
}
m=5;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
printf(" *");
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
m=m-2;
}
for(i=1;i<=7;i++)
printf(" *");
printf("\n");
m=1;
for(i=3;i>=1;i--)
{
for(j=1;j<=i;j++)
printf(" *");
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
m=m+2;
}
m=1;
for(i=7;i>=1;i=i-2)
{
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
for(k=1;k<=m;k++)
printf(" ");
m++;
}
getch();
return(0);
}
Thanking you friends......
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,m;
clrscr();
m=3;
for(i=1;i<=7;i=i+2)
{
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
m--;
}
m=5;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
printf(" *");
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
m=m-2;
}
for(i=1;i<=7;i++)
printf(" *");
printf("\n");
m=1;
for(i=3;i>=1;i--)
{
for(j=1;j<=i;j++)
printf(" *");
for(k=1;k<=m;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
m=m+2;
}
m=1;
for(i=7;i>=1;i=i-2)
{
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
for(k=1;k<=m;k++)
printf(" ");
m++;
}
getch();
return(0);
}
Thanking you friends......
No comments:
Post a Comment
Please Give Me Your Views