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
Is this program statement valid? INT = 10.50;
Can variables be declared anywhere in c?
What does the file stdio.h contain?
Why doesnt the call scanf work?
What is the size of empty structure in c?
What is the benefit of using #define to declare a constant?
What is an expression?
how logic is used
How do we make a global variable accessible across files? Explain the extern keyword?
Can you tell me how to check whether a linked list is circular?
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.
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
What is an arrays?
What is page thrashing?
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