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 / vidyullatha

#include<stdio.h>

main()
{
int i,j,k,l;
int space=3;
int cnt = 1;
int track=1;
for(i=0;i<4;i++)
{
for(j=1;j<=space;j++)
{
printf(" ");
}
for(k=1;k<=cnt;k++)
{
printf("%d ",k);
}
for(l=k-1;l<track;l++)
{
printf("%d ",track-l);
}
space--;
cnt++;
track=track+2;
printf("\n");
}
space=1;
cnt=3;
track=5;
for(i=0;i<3;i++)
{
for(j=1;j<=space;j++)
{
printf(" ");
}
for(k=1;k<=cnt;k++)
{
printf("%d ",k);
}
for(l=k-1;l<track;l++)
{
printf("%d ",track-l);
}
space++;
cnt--;
track=track-2;
printf("\n");
}
}

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 the correct code to have following output in c using nested for loop?

617


Explain function?

667


what type of questions arrive in interview over c programming?

1565


When should a type cast be used?

581


What are the salient features of c languages?

631






Can you apply link and association interchangeably?

682


Why isnt any of this standardized in c?

643


Explain enumerated types.

607


Is it better to use a macro or a function?

659


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14980


How can you find out how much memory is available?

620


Write a program to swap two numbers without using a temporary variable?

617


What is the benefit of using const for declaring constants?

594


What is the significance of an algorithm to C programming?

602


What is the argument of a function in c?

581