Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

function c++

#include <iostream>
using namespace std;
// Input a,b
// Output Combination a!/b!(a-b)!
	int fac(int x){
	int s=1;
	for(int i=x;i>0;i--){
		s*=i;
	}
	return s;
	}
	int con (int x,int y){
	int c;
	c=fac(x)/(fac(y)*fac(x-y));
	return c;
	}
	int main(){
	int a,b;
	cout<<"Enter the first number : ";
	cin >> a;
	cout<<"Enter the second number : ";
	cin >> b;
	cout<<"The conbination of these number : ";
	cout<<con(a,b);
	return 0;
	}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #function
ADD COMMENT
Topic
Name
3+3 =