Hello everyone!!!
I have the following pseudocode and I'm not exactly sure how/where to plug it into my code. I am still very lost concerning programing so please bear with my ignorance...:)
/* pseudocode for Binomial
Coefficients */
int binomial(int n, int k)
{
If (n < k) Then return (0)
Else
{
Set denominator = 1*2*...*k
Set numerator = (n-k+1)*(n-k+2)*...*(n-1)*n
return (numerator / denominator)
} // else
End if
}
This is my code below but from line 38, I'm not sure what to do next:
#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 = binomial(n,k);
cout << "Binomial number " << n << "C" << k
<< " = " << result << endl ;
return (0) ;
}
int binomial(int n, int k)
{
int numerator, denominator ;
int i ; // needed to compute numerator & denominator
if (n < k) Then
{
return (0) ;
}
else
{
denominator = 1*2*...*k ;
for ( i = : <= ; i=i+1)
denominator = * ;
write code to compute numerator, along similar lines
return ( ) ; write return value
}