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
What is pragma c?
why we wont use '&' sing in aceesing the string using scanf
What is binary tree in c?
How many data structures are there in c?
What is the use of typedef in c?
What is the difference between #include and #include 'file' ?
What is the best style for code layout in c?
given post order,in order construct the corresponding binary tree
Can the “if” function be used in comparing strings?
Explain modulus operator. What are the restrictions of a modulus operator?
What is d scanf?
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
Is sizeof a keyword in c?
Is it cc or c in a letter?
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