473,485 Members | 1,414 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Errror message: Extra parameter in call function

1 New Member
When I'm calling a function
f=fact(a) then error message is showing up "Extra parameter in call to fact()

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <conio.h>
  3. void main ()
  4. {
  5.            int a;
  6.            long f,fact();
  7.            clrscr();
  8.            printf ("\n Enter a Number : ");
  9.            scanf ("%d",&a);
  10.            f=fact(a);
  11.            printf ("\n The Factorial of %d is : %ld",a,f);
  12.            getch();
  13. }
  14.        long fact(int b)
  15.  {
  16.      int i;
  17.      long f=1;
  18.      for (i=1;i<=b;i++)
  19.             f=f*i;
  20.             return(f);
  21. }
Jan 20 '21 #1
3 5124
weaknessforcats
9,208 Recognized Expert Moderator Expert
Your function prototype says the fact function has no arguments. The prototype should be the same as the first line of the function:

long fact(int);
Jan 20 '21 #2
AjayGohil
83 New Member
Hello,

Declaration of function is not proper, use long fact(int a) or you can declare function globally outside the main function.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <conio.h>
  3. long fact(int a) ;
  4. void main ()
  5. {
  6.            int a;
  7.            long f;
  8.            clrscr();
  9.            printf ("\n Enter a Number : ");
  10.            scanf ("%d",&a);
  11.            f=fact(a);
  12.            printf ("\n The Factorial of %d is : %ld",a,f);
  13.            getch();
  14. }
Jan 27 '21 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Not quite correct.

When you use:

long f;
Int a;
....etc...

f = fact(a );

The compiler must already seen the code for the function. Otherwise the compiler can't know if you are using the function correctly.

Therefore, you put the function code in your file outside of main(). Unfortunately, if you need this function in another implementation file you must make a copy of the function code and paste it in the second file outside of any function and before the first call.

Everything works but you now have two copies of the function code. Duplicate code is a big no-no.

You avoid the duplicate by erasing all of the function code except the first line:

long fact(int);

This is the function prototype. It tells the compiler that there is fact function with an int argument
that returns an int but the function code is somewhere else. Now instead generating an error, the compiler generates an "unresolved external reference". This hands the responsibilty of finding the function code and linking it to the function calls to the linker.
Jan 27 '21 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
652
by: Lucy Randles | last post by:
I've written a VBA function that I then need to call in a form. Previously to do this I have written the call procedure in the same module as the function - i.e. Function callfunctionname() Call...
2
10174
by: PawelR | last post by:
Hello Group, In my application I have few class, and I want call function with "master class". This is as master form (startClass) and option window (ClassA). My question is how call function...
4
2835
by: Dave | last post by:
I have a program that I've written a class for. I need to call the function in the program from the class. When I try to call the function I receive the error, the name xxx does not exist in the...
2
3026
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
7
2669
by: Tiraman | last post by:
Hi , I have 3 files , middle.aspx file include the header.aspx and footer.aspx files . in each of the include files there is a function and from some reason the call to the Footer() function...
12
5751
by: leaf | last post by:
Hi, How to call function at runtime, based on a struct that contains the information for the function call: struct func_to_call { int function_id; // function id to call unsigned int nparams;...
1
5151
by: Khai Doan | last post by:
I have function A, which need to call function B with the exact same argument list. What is the correct way to do this? I had function A: function A { B(arguments); } but it does not...
5
3144
by: Dave | last post by:
I am using some recipes to do some calculation. But there are situation that I need to give extra parameters to the existing function. For example, the recipe has a function called: foo (int x,...
9
4697
by: Andrew Poulos | last post by:
Say I have this: var foo = function(x, y) { return x + y; }; var bar = function(fname, param1, param2) { /* * how do I call the function "foo" * and pass parameters to it?
1
3307
by: intermanch | last post by:
how call function php($varible) into javascript withod ajax: <!-- this code only call funnctions php but how call function php intermanch@gmail.com www.intermanch.blogfa.com
0
7085
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6957
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6820
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5410
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4544
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3049
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3053
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1371
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.