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
How can you convert integers to binary or hexadecimal?
Does c have circular shift operators?
Is c procedural or functional?
The difference between printf and fprintf is ?
What is pre-emptive data structure and explain it with example?
Explain how can I pad a string to a known length?
What is a null string in c?
Explain threaded binary trees?
What is the difference between malloc calloc and realloc in c?
Explain main function in c?
What is a shell structure examples?
What was noalias and what ever happened to it?
What is the difference between formatted&unformatted i/o functions?
What's the difference between constant char *p and char * constant p?
How many types of operators are there in c?