# How to declare function call?

Page 1 of 1

## 7 Replies - 384 Views - Last Post: 14 August 2011 - 09:41 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=243494&amp;s=3d21a17f70eb30c7cfad3f3d5a0f0f40&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 scoobydoobie

Reputation: 0
• Posts: 9
• Joined: 14-August 11

# How to declare function call?

Posted 14 August 2011 - 07:46 AM

This is for a homework assignment. I'm working on a code that incorporates a function call and determines the binomial coefficients of n and k. I've corrected several of the errors, but keep getting "error C3861: 'function': identifier not found" when I compile the code. I used "foo", "int foo", and "function" to try and compile the program but no luck. The beginning portion of the code is as follows:

```#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 function call (n, k) ;

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

return (0) ;
}

```

Can someone point me in the right direction? Am I not declaring the function properly?

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

This post has been edited by JackOfAllTrades: 14 August 2011 - 09:39 AM

Is This A Good Question/Topic? 0

## Replies To: How to declare function call?

### #2 MathiasVP

Reputation: 27
• Posts: 154
• Joined: 08-August 10

## Re: How to declare function call?

Posted 14 August 2011 - 08:00 AM

First of all use [ code ] [ /code ] tags to format your code properly on the forum.
Second of all don't you think that this line:

```result = Need function call (n, k) ;

```

looks only half finished? You've written a function prototype for a function called binomial(int n, int k), so I suspect that it's the one you're trying to call?
Assuming that you've written the function you should call it like this:
```result = binomial(n, k);

```

### #3 jimblumberg

Reputation: 3057
• Posts: 9,303
• Joined: 25-December 09

## Re: How to declare function call?

Posted 14 August 2011 - 08:01 AM

First use code tags when posting code.

Second show how you are trying to:
1. Declare the function.
2. Implement the function.
3. Call the function.

Jim

### #4 scoobydoobie

Reputation: 0
• Posts: 9
• Joined: 14-August 11

## Re: How to declare function call?

Posted 14 August 2011 - 08:21 AM

Okay, that took care of that error; however, when I compile the code now, I get two new errors: "error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup" and "fatal error LNK1120: 1 unresolved externals." The called environment looks like this:

```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 = 1 ; i <= k ; i++)
denominator =  denominator * i ;
numerator = n ;
for (i = 1 ; i >= n ; i ++)
numerator = numerator / i ;
return ( numerator / denominator ) ;
}
}
```

Again, this is a homework assignment and I'm not looking for the answer. I just need to know where my errors are so I can fix them. Thanks Jim and Mathias.

This post has been edited by JackOfAllTrades: 14 August 2011 - 09:40 AM
Reason for edit:: Fixed code tags

### #5 MathiasVP

Reputation: 27
• Posts: 154
• Joined: 08-August 10

## Re: How to declare function call?

Posted 14 August 2011 - 08:26 AM

This is a linking error so it has nothing to do with your code.

Rather it looks like you've built the project wrong. Try creating a new project and copy/paste the old code into the new project and make sure you choose to create a console application.

### #6 scoobydoobie

Reputation: 0
• Posts: 9
• Joined: 14-August 11

## Re: How to declare function call?

Posted 14 August 2011 - 08:31 AM

Mathias,

Thanks, I was finally able to compile. Why choose console application over win32 project? Just curious what the difference is. Thanks again.

### #7 MathiasVP

Reputation: 27
• Posts: 154
• Joined: 08-August 10

## Re: How to declare function call?

Posted 14 August 2011 - 08:38 AM

Basically you have 2 options (Actually you have more, but let's leave it at 2 for now) when choosing your project:

Console applications and Win32 applications.

Console applications are, like yours, run with a command line interface like you see in your own application. This type of application has it's entry point in the main() function.

On the other hand you have Win32 applications, which is used to create programs that has the "Windows"-feeling to it. You can read alot more about Win32 applications here.
These applications has it's entry point in the WinMain() function and generally focuses on the concept of the message loop.

• Saucy!

Reputation: 5672
• Posts: 22,528
• Joined: 23-August 08

## Re: How to declare function call?

Posted 14 August 2011 - 09:41 AM

The RIGHT way to use code tags:

If that's too complicated, see the link my signature.