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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we change the value of constant variable in c?

1067


What is the difference between functions abs() and fabs()?

1166


What does calloc stand for?

1178


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1290


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

2261


Explain how can I open a file so that other programs can update it at the same time?

1128


What is malloc return c?

1034


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

3186


i have a written test for microland please give me test pattern

2744


Explain is it valid to address one element beyond the end of an array?

1229


How do I convert a string to all upper or lower case?

1136


What are preprocessor directives in c?

1109


Was 2000 a leap year?

1062


How is actual parameter different from the formal parameter?

1030


What is string function in c?

996