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

What is pragma c?

620


why we wont use '&' sing in aceesing the string using scanf

1787


What is binary tree in c?

626


How many data structures are there in c?

620


What is the use of typedef in c?

592






What is the difference between #include and #include 'file' ?

610


What is the best style for code layout in c?

634


given post order,in order construct the corresponding binary tree

2325


Can the “if” function be used in comparing strings?

599


Explain modulus operator. What are the restrictions of a modulus operator?

603


What is d scanf?

599


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1455


Is sizeof a keyword in c?

586


Is it cc or c in a letter?

571


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

640