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
Here is a neat trick for checking whether two strings are equal
Where local variables are stored in c?
What is an expression?
What is a function simple definition?
Do variables need to be initialized?
How can I make it pause before closing the program output window?
explain what are pointers?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
What are reserved words?
Explain the term printf() and scanf() used in c language?
how to create duplicate link list using C???
What is the use of gets and puts?
What is c programing language?
Create a simple code fragment that will swap the values of two variables num1 and num2.
How do you use a pointer to a function?