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
What is the function of multilevel pointer in c?
What are the 5 data types?
What are the different categories of functions in c?
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
How can I run c program?
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
What are types of functions?
What is a pointer value and address in c?
4. main() { int c=- -2; printf("c=%d",c); }
Explain what math functions are available for integers? For floating point?
What is pragma in c?
What are keywords in c with examples?
How arrays can be passed to a user defined function
Tell me when is a void pointer used?
What is a double c?