Computer Science, asked by vridhibhatia5744, 1 year ago

Write a function fact(int n)to find factorial of number n.include a main class to find value of s where s=n!/m!(n-m)!

Answers

Answered by aalaparunp66okp
8

#include<iostream.h>

#include<conio.h>

void fact(int n, int &facto)

{

int i;

for(i=1;i<n;i++)

       facto*=i;

}

void main()

{

clrscr();

int n,m,fn,fm,a,fa,s;

fn=fm=fa=1;

cout<<"Enter a number : ";

cin>>n;

cout<<"Enter a number : ";

cin>>m;

fact(n,fn);

fact(m,fm);

a=n-m;

fact(a,fa);

s=fn/(fm*fa);

cout<<" Factorial of "<<n<<" = "<<fn<<'\n';

cout<<" Factorial of "<<m<<" = "<<fm<<'\n';

cout<<" Factorial of "<<a<<" = "<<fa<<'\n';

cout<<" s = "<<s<<'\n';

getch();

}

Answered by Jeevanaagayathri
0

#include<iostream.h>

#include<conio.h>

void fact(int n, int &facto)

{

int i;

for(i=1;i<n;i++)

       facto*=i;

}

void main()

{

clrscr();

int n,m,fn,fm,a,fa,s;

fn=fm=fa=1;

cout<<"Enter a number : ";

cin>>n;

cout<<"Enter a number : ";

cin>>m;

fact(n,fn);

fact(m,fm);

a=n-m;

fact(a,fa);

s=fn/(fm*fa);

cout<<" Factorial of "<<n<<" = "<<fn<<'\n';

cout<<" Factorial of "<<m<<" = "<<fm<<'\n';

cout<<" Factorial of "<<a<<" = "<<fa<<'\n';

cout<<" s = "<<s<<'\n';

getch();

}

Read more on Brainly.in - https://brainly.in/question/8307674#readmore

Similar questions