answersLogoWhite

0

// function declaration

void functionName (int, double);

// function definition

void functionName (int x, double y) {

// implementation...

}

A function declaration informs the compiler of the function's type, its name and the number and type of its arguments. A declaration is required so the compiler knows what the name represents and how it may be used, but it is not necessary to know what it does or how it does what it does.

A definition is also a declaration, but also includes the names of its formal arguments and provides the implementation details of the function itself. A declaration without a definition is not required, however declarations do help programmers to see the interface without being distracted by the implementation details. By placing declarations in a header file, multiple translation units can make use of the same declaration regardless of which translation unit defines the implementation. This also makes it possible to create functions that depend on each other because it would be impossible to define a function that used another function that hadn't yet been declared.

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

Difference between declaring a variable and definition a variable?

Declaration is a promise: 'I will define (or has defined) this variable/function somewhere else'.


What is the difference between declaration and definition?

definition: the meaning or description of person/place/thing declaration: taking a stand


What is the difference between declaration and a definition in c plus plus?

A declaration is an incomplete type whereas a definition is a complete type.


What is the difference between declaration and initialization?

Perhaps an example will help. extern int value; /* declaration */ int value; /* definition */ int value= 20; /* definition with initialization */


What is the difference between declaration and a definition in C with small example?

declaration examples:int main (void);extern int somevariable;definition examples:int main (void) { puts ("Hello world"); return 0; }int somevariable;


Whats the difference between Virginia Declaration of Rights and Declaration of Rights?

There is a difference


Deifference between declaration and definition?

Declaring a variable or function reserves an entry in a symbol table for that function or variable (entries in a symbol table eventually become memory addresses during linkage). Defining a variable or function actually specifies the value to be stored in the memory location specified and/or the code that should be compiled. Examples: Declaration: int foo(); // Declares a function. int bar; // Declares a variable. Definition: int foo() { printf("Hello World"); } bar = 5; Declaration and definition: int bar = 5;


What is the Difference between Kotler's marketing definition and AMA marketing definition?

answering "What is the Difference between kotler's marketing definition and AMA marketing definition?"


What is the difference between declaring variable and initializing variables?

Actually, there is a third step, call definition. Declaration is a statement to the compiler of what type an identifier is, definition is the allocation of memory for that identifier, and initialization is the assignment of an initial value to that identifier. Usually, declaration and definition are done together, but you can also add initialization in that step if desired. int a; /* declaration and definition */ a = 1; /* initialization */ int a = 1; /* declaration, definition, and initialization */ For the case of seperate declaration and definition, consider the struct... struct _mystruct { int a; }; /*declaration */ struct _mystruct mystruct; /* definition */ struct _mystruct { int a; } mystruct; /*declaration and definition */ Note: To be more precise: struct _mystruct; /* struct declaration */ struct _mystruct { int a; }; /* struct definition */ typedef struct _mystruct MYTYPE; /* type definition */ extern struct _mystruct mystructvar; /* variable declaration */ struct _mystruct mystructvar; /* variable definition */ struct _mystruct mystructvar = {7} ; /* variable definition with initialization */ struct _mystruct { int a; } mystruct; /* struct definition and variable definition */ extern struct _mystruct { int a; } mystruct; /* struct definition and variable declaration */


What is the difference between function and recursive function?

I will explain in the easiest way the difference between the function and recursive function in C language. Simple Answer is argument of the function is differ but in the recursive function it is same:) Explanation: Function int function(int,int)// function declaration main() { int n; ...... ...... n=function(a,b); } int function(int c,int d) { ...... ...... ...... } recursive Function: int recursive(int,int)// recursive Function declaration main() { int n; ..... ..... ..... ..... n=recursive(a,b); } int recursive(int a,int b) { ..... .... .... .... } Carefully see, In the recursive Function the function arguments are same.


Example of fundamental difference between a polynomial function and an exponential function?

fundamental difference between a polynomial function and an exponential function?


Difference between library file and header file?

EX: pgm #include<stdio.h> main() { printf("haiii"); } Header file: (1) contains the function(printf) declaration (2) during preprocessing, the printf function is replaced by the function declaration Library file : (1) contains the function(printf) definition (2) during linking, the function declaration is replaced with the function definition.obviously, everything will be in object while linking