Thu Apr 23, 2009 1:36 am
/* Program to compute binomial coefficients */
/* */
/* Inputs: (keyboard) */
/* Two positive integers (n & k) */
/* */
/* Output: */
/* Corresponding binomial coefficient (nCk) */
/* */
/* Algorithm: see attached description */
/****************************************************/
#include <iostream>
using namespace std ;
int binomial(int n, int k) ; // function prototype
int main()
{
int n, k ; // parameters for the binomial number
int result ;
cout << endl ;
// read in n & k
cout << "Enter n (positive integer) : " ;
cin >> n ;
cout << "Enter k (positive integer) : " ;
cin >> k ;
result = NEED TO WRITE FUNCTION CALL HERE
cout << "Binomial number " << n << "C" << k
<< " = " << result << endl ;
return (0) ;
}
// ********************************************************
int binomial(int n, int k)
/* Computes the binomial coefficient nCk */
/* */
/* Inputs: */
/* n, k (integers) */
/* */
/* Output: */
/* binomial coefficient nCk (integer) */
{
int numerator, denominator ;
int i ; // needed to compute numerator & denominator
ALL THIS STUFF NEEDS TO BE CHANGED
if ( ? ) Write if-test
{
return( ? ) ; Write return value
}
else
{
denominator = ? ; Write initial value
for (i = ? ; i <= ? ; i = i+1)
denominator = ? * ? ;
Write code to compute numerator, along similar lines
return ( ? ) ; Write return value
}
}
Sat Aug 08, 2009 7:21 pm
Fri Aug 14, 2009 4:19 am
Fri Aug 14, 2009 12:29 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.