/****************************************************/
/* File: Binomial Numbers.cpp */ 
/* */ 
/* Created by: Regine R Calinda */ 
/* Date: November 9, 2009 */ 
/* */ 
/* 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 = binomial (n,k) ; 

cout << "Binomial number " << n << "C" << k
<< " = " << result << endl ; 

return (0) ;
} // end main


// ******************************************************** 

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 

if (n<k) 
{
return(0) ;
}
else
{
denominator = k ; 

for (i = 0  ; i <=  ; i = i+1)
denominator =  n ;

return (n) ;
} // end if 
} // end function binomial

>c:\users\genie\documents\visual studio 2008\projects\binomial numbers\binomial numbers\binomial numbers.cpp(71) : error C2059: syntax error : ';'

1>c:\users\genie\documents\visual studio 2008\projects\binomial numbers\binomial numbers\binomial numbers.cpp(71) : error C2143: syntax error : missing ';' before ')'

1>c:\users\genie\documents\visual studio 2008\projects\binomial numbers\binomial numbers\binomial numbers.cpp(71) : error C2143: syntax error : missing ';' before ')'

1>Build log was saved at "file://c:\Users\genie\Documents\Visual Studio 2008\Projects\Binomial Numbers\Binomial Numbers\Debug\BuildLog.htm"
1>Binomial Numbers - 3 error(s), 0 warning(s)

line 71 contains a syntax error. See if you can find it.

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.