STUDY
Would you like to react to this message? Create an account in a few clicks or log in to continue.

向下
avatar
Musturi
文章數 : 3
積分 : 9
注冊日期 : 2020-05-19

Write a complete C++ program to calculate the value C where C = n! / ( k! * ( n + k ) ! – k ) using function. Empty Write a complete C++ program to calculate the value C where C = n! / ( k! * ( n + k ) ! – k ) using function.

周二 8月 18, 2020 8:35 pm
Write a complete C++ program to calculate the value C where C = n! / ( k! * ( n + k ) ! – k ) using function.
avatar
ARYAN P.
Contributor
文章數 : 18
積分 : 20
注冊日期 : 2020-05-01

Write a complete C++ program to calculate the value C where C = n! / ( k! * ( n + k ) ! – k ) using function. Empty 回復: Write a complete C++ program to calculate the value C where C = n! / ( k! * ( n + k ) ! – k ) using function.

周三 8月 19, 2020 12:34 am
代碼:
#include<iostream>
using namespace std;
double fact(double N)//function to calculate factorial of given number
{
  if(N>0)
      return N*fact(N-1);
  else
      return 1;
}
int main()
{
  double n,C,k;//declaring all variables as double
  cout<<"C = n! / ( k!* ( n + k)! - k)"<<endl;//display the Expression to user
  cout<<"\nEnter n:";
  cin>>n;
  cout<<"Enter k:";
  cin>>k;
  C=fact(n)/(fact(k)*(fact(n+k))-k);//calculating value of c
  cout<<"\nC = "<<C;//prints value of c
}
回頂端
這個論壇的權限:
無法 在這個版面回復文章