1
2 2
3 3 3
He was asking the code in NATURAL language which no one knows. I found a P.S in his mail saying that "If u cud give me the C code for this logic I can write the equivalent NATURAL language". I have C in my system here , when I started coding I thought this is really a difficult logic to execute. Then I spent nearly 20 minutes with pen and paper with different combinations of FOR loops and successsfuly got the required sequence.
scanf("%d",&n);
k=n-1;
for(i=1;i<=n;i++)
{
for(j=1;j<=k;j++)
{
printf(" ");
}
k--;
for(j=1;j<=i;j++)
{
printf("%d ",i);
}
printf("\n");
}
4 comments:
Hi vivek,
u posted a good event with suitable epitome,very happy to see this in the blog.I know how much u tried and get the code executed in minutes.Damn cute to see your happiness and the pride in your face after succesful execution of that program.
Thank U
great work man...
u had always been and will always b our tech genious coder....
Hey vivek,i got a question with same logic but i have to design a diamond shape in my campus interview..
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
Post a Comment