Hello all!! I've been working on this code for a while now and I'm still lost. Can anyone tell me what's wrong with this code please???
I know Line 44 is missing something but I'm not sure what goes there, here is the pseudocode as well:

/* 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
}

#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 = ; //Write inital value
      
      for ( i = n : <= k ; i = i + 1 )
      denominator = sum * 1 ;
      numerator = (n-k+1)*(n-k+2)*...*(n-1)*n=
      (n-(k-1))*(n-(k-2))*...*(n-1)*(n-0)=
      (n-0)*(n-1)*... (n-(k-2))*(n-(k-1))

     
     return (numerator / denominator) ; 
}

use separate loops to calculate the numerator and denominator.

Thanks! Can you give me an example of what you mean and specify the line to which you are referring?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.