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 / sandip pal

#include<stdio.h>
#include<conio.h>
int ncr(int,int);
int fact(int);
void main()
{
int i,j;
clrscr();
for(i=0;i<=5;i++)
{
printf("\n\n");
for(j=0;j<=5-i;j++)
printf(" ");
for(j=0;j<=i;j++)
printf(" %2d ",ncr(i,j));
}
getch();
}
int ncr(int n,int r)
{
int f;
f=fact(n)/(fact(n-r)*fact(r));
return f;
}
int fact(int n)
{
if(n==0)
return 1;
else
n=n*fact(n-1);
return n;
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is this program statement valid? INT = 10.50;

690


Can variables be declared anywhere in c?

626


What does the file stdio.h contain?

608


Why doesnt the call scanf work?

679


What is the size of empty structure in c?

597






What is the benefit of using #define to declare a constant?

611


What is an expression?

661


how logic is used

1504


How do we make a global variable accessible across files? Explain the extern keyword?

1427


Can you tell me how to check whether a linked list is circular?

781


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

839


the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b

1908


What is an arrays?

658


What is page thrashing?

655


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

650