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
What is the correct code to have following output in c using nested for loop?
Explain function?
what type of questions arrive in interview over c programming?
When should a type cast be used?
What are the salient features of c languages?
Can you apply link and association interchangeably?
Why isnt any of this standardized in c?
Explain enumerated types.
Is it better to use a macro or a function?
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.
How can you find out how much memory is available?
Write a program to swap two numbers without using a temporary variable?
What is the benefit of using const for declaring constants?
What is the significance of an algorithm to C programming?
What is the argument of a function in c?