coming from version 6

I have been learning to use version 6, and got 2005 through school. When I try to compile and execute a program that works fine on version 6, I can't get it to work on 2005. I use F7 to compile, and it gives the report:

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

How do I get it to make the program run

/****************************************************/
/* File: Assign5.cpp */
/* */
/* Created by: John Smith */
/* Date: May 21, 2006 */
/* */
/* 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) ;
}

/* ***************************************/
/* Computes the binomial coefficient nCk */
/* */
/* Inputs: */
/* n, k (integers) */
/* */
/* Output: */
/* binomial coefficient nCk (integer) */
/* ***************************************/

int binomial(int n, int k)
{
int numerator, denominator ;
int i ; // needed to compute numerator & denominator

if (n < k)
{
return 0;
}
else
{
denominator = 1; // initial value

for (i = 1; i <= k; i = i+1)
{
denominator = denominator * i;
}

numerator = 1; // initial value
for (i = n-k+1; i <= n; i = i+1)
{
numerator = numerator * i;
}

// OR:
// for (i = 1; i <= k; i = i+1)
// {
// numerator = numerator * (n - k + i);
// }

return numerator / denominator;
}
}



Answer this question

coming from version 6

  • Christian Winter

    It didn't build your program. Try Build + Clean first, then Build + Build, then Debug + Start Debugging.


  • Shining Arcanine

    I tried doing that, and it gave me the same thing I had before.
  • coming from version 6