Hiiii friends today i am trying to print the follwing pattern,just see the code and give me your views about this code,this code is so simple and you can easily understand it.
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,l;
clrscr();
l=1;
printf("\n HERE IS YOUR PATTERN:\n");
for(i=1;i<=9;i=i+2)
{
for(k=l;k<=4;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
l++;
}
l=1;
for(i=7;i>=1;i=i-2)
{
for(k=1;k<=l;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
l++;
}
l=3;
for(i=3;i<=5;i=i+2)
{
for(k=1;k<=l;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
l--;
}
getch();
return(0);
}
Thanks Guys...........
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,l;
clrscr();
l=1;
printf("\n HERE IS YOUR PATTERN:\n");
for(i=1;i<=9;i=i+2)
{
for(k=l;k<=4;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
l++;
}
l=1;
for(i=7;i>=1;i=i-2)
{
for(k=1;k<=l;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
l++;
}
l=3;
for(i=3;i<=5;i=i+2)
{
for(k=1;k<=l;k++)
printf(" ");
for(j=1;j<=i;j++)
printf(" *");
printf("\n");
l--;
}
getch();
return(0);
}
Thanks Guys...........
Awesome. I am a beginner and this article helped me to resolve the problem .Thank
ReplyDeleteyou author and the whole expect team.
http://www.wikitechy.com/view-article/java-program-to-print-a-stars-and-numbers-in-triangular-pattern
Both are really good,
Cheers,
Venkat
nice post
ReplyDeleteC Program to print pattern