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
Can we change the value of constant variable in c?
What is the difference between functions abs() and fabs()?
What does calloc stand for?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Explain how can I open a file so that other programs can update it at the same time?
What is malloc return c?
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
i have a written test for microland please give me test pattern
Explain is it valid to address one element beyond the end of an array?
How do I convert a string to all upper or lower case?
What are preprocessor directives in c?
Was 2000 a leap year?
How is actual parameter different from the formal parameter?
What is string function in c?