Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE
FOLLOWING SERIES
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1

Answers were Sorted based on User's Feedback



SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE FOLLOWING SERIES 1 1 2 1 ..

Answer / sakthivel

/*
Written By : Sakthivel
Tested By : Rajavelraj
*/




#include<stdio.h>
#include<conio.h>

public void main()
{

int i,j,k,l,a=1;

for(i=1;i<=4;i++)
{
for(j=4;j>i;j--)
{
printf(" ");
}

for(k=1;k<=i;k++)
{
printf("%d",k);
}

for(l=i;l>1;l--)
{
printf("%d",l-1);
}

printf("\n");
}

for(i=4;i>1;i--)
{
for(j=1;j<=a;j++)
{
printf(" ");
}

for(k=1;k<i;k++)
{
printf("%d",k);
}

for(l=k-1;i>1;l--)
{
printf("%d",l-1);
}
a=a+1;
printf("\n");
}
getch();
}

Is This Answer Correct ?    2 Yes 2 No

SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE FOLLOWING SERIES 1 1 2 1 ..

Answer / vidyullatha

#include<stdio.h>

main()
{
int i,j,k,l;
int space=3;
int cnt = 1;
int track=1;
for(i=0;i<4;i++)
{
for(j=1;j<=space;j++)
{
printf(" ");
}
for(k=1;k<=cnt;k++)
{
printf("%d ",k);
}
for(l=k-1;l<track;l++)
{
printf("%d ",track-l);
}
space--;
cnt++;
track=track+2;
printf("\n");
}
space=1;
cnt=3;
track=5;
for(i=0;i<3;i++)
{
for(j=1;j<=space;j++)
{
printf(" ");
}
for(k=1;k<=cnt;k++)
{
printf("%d ",k);
}
for(l=k-1;l<track;l++)
{
printf("%d ",track-l);
}
space++;
cnt--;
track=track-2;
printf("\n");
}
}

Is This Answer Correct ?    0 Yes 0 No

SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE FOLLOWING SERIES 1 1 2 1 ..

Answer / shobha

To Print it in linear fashion:
#include <stdio.h>

main()
{
//1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 2 1 1 2 1 1
int i =0,j =0,k=0 ;

for(i =1; i<=4; i++)
{
for (j=1;j<=i;j++ )
printf("%d ",j);

for(j=i-1;j>=1;j--)
printf("%d ",j);
}
i--;

for(k = i-1;k >= 1;k--)
{
for (j=1;j<=k;j++ )
printf("%d ",j);

for(j=k-1;j>=1;j--)
printf("%d ",j);

}
}

Is This Answer Correct ?    0 Yes 0 No

SIR PLS TELL ME THE CODE IN C LANGUAGE TO PRINT THE FOLLOWING SERIES 1 1 2 1 ..

Answer / sho

#include <stdio.h>

main()
{
int i =0,j =0,k=0,l=0;

for(i =1; i<=4; i++)
{
l= 4-i;
while(l-- > 0)
{
printf(" ");
}

for (j=1;j<=i;j++ )
printf("%d ",j);

for(j=i-1;j>=1;j--)
printf("%d ",j);

printf("\n");
}
i--;

for(k = i-1;k >= 1;k--)
{
l= 4-k;
while(l-- > 0)
{
printf(" ");
}

for (j=1;j<=k;j++ )
printf("%d ",j);

for(j=k-1;j>=1;j--)
printf("%d ",j);
printf("\n");

}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

what is the output of the below code? main( ) { printf ( "\nOnly stupids use C?" ) ; display( ) ; } display( ) { printf ( "\nFools too use C!" ) ; main( ) ; }

3 Answers  


What is Generic pointer? What is the purpose of Generic pointer? Where it is used?

3 Answers  


implement general tree using link list

1 Answers   Wipro,


Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d

1 Answers   TCS,


wat is the meaning of c?

9 Answers   CTS, IBM, Wipro,


Explain what does a function declared as pascal do differently?

0 Answers  


convert 0.9375 to binary

2 Answers   CTS, TANCET,


How can I read and write comma-delimited text?

0 Answers  


What is volatile c?

0 Answers  


If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i give int a[5] = {5}; then 5 0 0 0 0 is ans. what will I do for all element 5 5 5 5 5 in a single statement???

3 Answers   Amdocs, IBM,


related to rdbms query .

2 Answers  


what is the disadvantage of using macros?

1 Answers   Wipro,


Categories