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
Explain what is operator promotion?
Why is main function so important?
How can I remove the trailing spaces from a string?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
What are the disadvantages of a shell structure?
What is the process to generate random numbers in c programming language?
Explain how do you generate random numbers in c?
What is a memory leak? How to avoid it?
How do you initialize pointer variables?
What is difference between Structure and Unions?
What is malloc() function?
What is meant by int main ()?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
what do you mean by enumeration constant?