Write a C program to get the desired output.
1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
.
.
.
1 n..............n 1
Note: n is a positive integer entered by the user.
Answer Posted / guest
#include<conio.h>
#include<stdio.h>
void main()
{
int a[10],b[10];
int c=1,n=5;
a[0]=0;a[1]=1;a[2]=0;
b[0]=0;
printf("Enter no. of rows to print ");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
for(int j=n-2;j<0;j++)
printf(" ");
c++;
for(int k=0;k<c;k++)
{
b[k+1]=a[k]+a[k+1];
}
b[c]=0;
for(int k=1;k<=i+1;k++)
{
printf("%d ",a[k]);
}
printf("\n");
for(int k=0;k<i+3;k++)
a[k]=b[k];
}
getch();
}
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What is the sizeof () a pointer?
Explain the binary height balanced tree?
Explain how do you generate random numbers in c?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What are types of functions?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
Which is better malloc or calloc?
Why & is used in scanf in c?
State the difference between x3 and x[3].
Why do we use static in c?
What are the different data types in C?
What does emoji p mean?
How can I read/write structures from/to data files?
What are the various types of control structures in programming?