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


Please Help Members By Posting Answers For Below Questions

Why is structure padding done in c?

627


why return type of main is not necessary in linux

1686


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

673


what is ur strangth & weekness

1798


State two uses of pointers in C?

624






What is the process of writing the null pointer?

594


What is c language & why it is used?

566


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

639


Which is the memory area not included in C program? give the reason

1487


What are actual arguments?

637


What is malloc and calloc?

556


Is javascript based on c?

582


Explain how do you convert strings to numbers in c?

582


What is function prototype in c with example?

561


Who developed c language and when?

567