answersLogoWhite

0


Best Answer

Before a function can be called the compiler needs to know the function's type and the number and type of its arguments to ensure the call is valid. This information is provided by the function declaration, which must be visible to the compiler prior to the point of the call (a forward declaration). With a two-pass compiler, the declaration may be placed before or after the call point.

Ideally, function declarations should be placed in a header file, with the functions grouped in some logical manner. For instance, all string-handling functions may be declared in a "string.h" header. in this way, the programmer need only include the header to ensure the declarations are consistent across all translation units that require those declarations.

In addition, all types required by the function must also be declared to the compiler. Again, these may be placed in a header to ensure the types are declared consistently.

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In order to execute a function in program what is needed first to do so?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why you have begin with main function?

You don't have, it's only the program-execution which begins with the main function, but it doesn't have to be the first function in the source-file.


What is the difference between dynamic and static binding?

Static binding is where the linker copies the called function into the program's executable image from the appropriate library and resolves the references to the function at compile/link time. The program contains a copy of the library function and does not need to load it at run time. Dynamic binding is where the linker inserts stub code into the program's executable image that references the appropriate library. The library function is then copied into memory at load or run time and references are resolved then. The program does not contain a copy of the library function, and the library must be accessible at load/run time. There are two kinds of dynamic binding. The first is load time, where the library must be loaded before the program starts to execute. In this case, if the library is not found, load fails and the program does not run. The second is run time, where the library must be loaded at the point of first access. This occurs after then program starts to execute, and the program can change its behavior depending on options or library availability.


What is the Use of main function in c language?

Any program source has to identify a memory location as the start of the program. The OS transfers control to this point of the program or module. In case of C programs, the starting module is NOT your program, but another initialisation routine, which has name lis c0s.obj, c0l.obj etc. This routine after doing initial housekeeping work, like storing program name, arguments, environment variables etc. in the stack, calls a routine by name main. How else are we going to tell the OS where to start ? At the end of executing the main() function, the control goes back to the routine from which the main was called and then to OS, which terminates the program.


How do you write a program to find out the square and cube of first ten natural numbers in gw basic?

First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.


What happen when a c program passes an array as a function argument?

When an array name is passed as a function argument, the address of the first element is passed to the function. In a way, this is implicit call by reference. The receiving function can treat that address as a pointer, or as an array name, and it can manipulate the actual calling argument if desired.

Related questions

What action is taken by CPU after reset to execute first instruction of program?

The fetch-execute cycle.


Why is it that sometimes when you run a program it will execute the previous program instead the current open program?

because the previous program is the first one to be interpreted that's why you need to re run the program to open the current program that you want to open


What is a main function in c plus plus?

It is the first function that gets called when the program is executed.


How do you make program specification?

you first of all state the function of the program. State the inputs that will be used,the algorithm and the outputs of the program.


What is the first step in the schedule preparation process and what is its end result?

Identify the Tasks; a list of all the tasks required to execute the program.


Why you have begin with main function?

You don't have, it's only the program-execution which begins with the main function, but it doesn't have to be the first function in the source-file.


What is the difference between dynamic and static binding?

Static binding is where the linker copies the called function into the program's executable image from the appropriate library and resolves the references to the function at compile/link time. The program contains a copy of the library function and does not need to load it at run time. Dynamic binding is where the linker inserts stub code into the program's executable image that references the appropriate library. The library function is then copied into memory at load or run time and references are resolved then. The program does not contain a copy of the library function, and the library must be accessible at load/run time. There are two kinds of dynamic binding. The first is load time, where the library must be loaded before the program starts to execute. In this case, if the library is not found, load fails and the program does not run. The second is run time, where the library must be loaded at the point of first access. This occurs after then program starts to execute, and the program can change its behavior depending on options or library availability.


What is the Use of main function in c language?

Any program source has to identify a memory location as the start of the program. The OS transfers control to this point of the program or module. In case of C programs, the starting module is NOT your program, but another initialisation routine, which has name lis c0s.obj, c0l.obj etc. This routine after doing initial housekeeping work, like storing program name, arguments, environment variables etc. in the stack, calls a routine by name main. How else are we going to tell the OS where to start ? At the end of executing the main() function, the control goes back to the routine from which the main was called and then to OS, which terminates the program.


What was the first space program started by nasa?

Mercury was the name of the first American Space program started by NASA. The goals were to see if humans can go to space and function normaly.


How do you write a program to find out the square and cube of first ten natural numbers in gw basic?

First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.


Why main is written in beginning of any c program?

Every C program requires at least one function to coordinate the calls to all other functions. This function acts as the entry point of the application and is called "main" to indicate that it is the main function of the program. Compilation always begins with the main function so that its first statement becomes the first instruction in the machine code. Since C++ derives from C it also requires a main function. However, every language must provide an entry point of some kind, even if it is simply the first function in a series of functions, otherwise the executable would not be able to execute. Libraries, such as dynamic link libraries, do not require a main function since they are intended to provide dynamic functionality in order to augment one or more executables. However, they can include an optional entry-point (such as DLLMain) that is executed whenever the library is loaded or unloaded (attached or detached from a process or thread). The entry point is used to both initialise the library when attached, and perform clean-up tasks when detached.


When first powered on the first instructions a computer will execute are stored in?

The BIOS.