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
Explain what is a const pointer?
Who invented bcpl language?
Can you please explain the difference between syntax vs logical error?
Explain why c is faster than c++?
How can I discover how many arguments a function was actually called with?
How do I get an accurate error status return from system on ms-dos?
What is indirection?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
Why doesn't C support function overloading?
In c language can we compile a program without main() function?
What does dm mean sexually?
What is pointer to pointer in c language?
What do you mean by dynamic memory allocation in c?
main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none