answersLogoWhite

0


Best Answer

A function's declaration must be visible within every translation unit that uses that function, thus multiple declarations are permitted. To ensure consistency across all translation units that use a function, the declaration is usually placed in a header which can be included wherever it is needed. Formal arguments need not be named in a declaration (they do not form part of the function's prototype), but named arguments can provide better documentation and need not match the names used by the definition, or indeed by any other declaration of the same function.

Note that a definition is itself a declaration, thus if a function is declared (but not yet defined), there has to be at least two declarations because the function must be defined somewhere.

The "one definition rule" (ODR) implies there can only ever be one definition of a function, however multiple definitions are permitted provided those definitions appear in different translation units and are token-for-token identical (including the names of formal arguments). Being token-for-token identical means there is only one definition.

Thus the correct answer is D: multiple declarations with one definition.

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is True in C programming A multiple fn definitions and multiple declarations B 1 declaration multiple fn definitions C 1 fn definition 1 declaration D multiple declaration 1 definition?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you define the definition section of a c program?

C programs don't have a definition section as such. C source files are composed from declarations and definitions, however the only requirement is that all user-defined identifiers be declared before they are used; the definition itself can literally be placed anywhere. However, a definition is itself a declaration so we really only need declarations when a definition is used by two or more source files or where two or more definitions refer to each other (cyclic dependants). Typically, we place declarations in header files which can then be included (via the #include compiler directive) in any source files that require them, thus ensuring all declarations are consistent. By organising declarations by their function we can include all related identifiers with a single #include directive. Declarations that are not actually used don't cost anything because declarations do not generate code. Definitions do generate code, but if the code is not used the only cost is in generating the code because unused code has neither internal or external linkages.


Is it true global variable may have several declaration but only one definition?

Yes, indeed it is. In all the declarations, you need to use the keyword "extern". Rgds, Karthick S.


What is Variable declaration and variable initialization?

...are important things in programming. Example: extern int variable; /* declaration */ int variable= 8; /* definition with initialization */


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


What are invalid variable names?

Invalid variable names are identifiers that are not recognised by the language compiler. All user-defined identifiers (both names and type definitions) must be introduced to the compiler by a declaration. A definition is also a declaration, however a definition is not required to use a name, only the declaration. However, all declarations must be defined somewhere. Different programming languages have different conventions for naming identifier. However, in most languages, a name must always begin with a letter or an underscore, never a digit, because a leading digit usually signifies a value and would only complicate the language compiler's implementation. Case-sensitive languages, such as C treat 'name', 'Name' and 'NAME' as being different identifiers while case-insensitive languages will treat them as being the same identifier.

Related questions

How do you define the definition section of a c program?

C programs don't have a definition section as such. C source files are composed from declarations and definitions, however the only requirement is that all user-defined identifiers be declared before they are used; the definition itself can literally be placed anywhere. However, a definition is itself a declaration so we really only need declarations when a definition is used by two or more source files or where two or more definitions refer to each other (cyclic dependants). Typically, we place declarations in header files which can then be included (via the #include compiler directive) in any source files that require them, thus ensuring all declarations are consistent. By organising declarations by their function we can include all related identifiers with a single #include directive. Declarations that are not actually used don't cost anything because declarations do not generate code. Definitions do generate code, but if the code is not used the only cost is in generating the code because unused code has neither internal or external linkages.


What is Unilateral Declaration of Independence?

That is a tautology. All declarations of independence are unilateral by definition. It just means one-sided.


Is it true global variable may have several declaration but only one definition?

Yes, indeed it is. In all the declarations, you need to use the keyword "extern". Rgds, Karthick S.


What is Variable declaration and variable initialization?

...are important things in programming. Example: extern int variable; /* declaration */ int variable= 8; /* definition with initialization */


C programming language bsc it notes?

different between defining value definition section and defining value declaration section


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


What are variable name?

Invalid variable names are identifiers that are not recognised by the language compiler. All user-defined identifiers (both names and type definitions) must be introduced to the compiler by a declaration. A definition is also a declaration, however a definition is not required to use a name, only the declaration. However, all declarations must be defined somewhere. Different programming languages have different conventions for naming identifier. However, in most languages, a name must always begin with a letter or an underscore, never a digit, because a leading digit usually signifies a value and would only complicate the language compiler's implementation. Case-sensitive languages, such as C treat 'name', 'Name' and 'NAME' as being different identifiers while case-insensitive languages will treat them as being the same identifier.


What are invalid variable names?

Invalid variable names are identifiers that are not recognised by the language compiler. All user-defined identifiers (both names and type definitions) must be introduced to the compiler by a declaration. A definition is also a declaration, however a definition is not required to use a name, only the declaration. However, all declarations must be defined somewhere. Different programming languages have different conventions for naming identifier. However, in most languages, a name must always begin with a letter or an underscore, never a digit, because a leading digit usually signifies a value and would only complicate the language compiler's implementation. Case-sensitive languages, such as C treat 'name', 'Name' and 'NAME' as being different identifiers while case-insensitive languages will treat them as being the same identifier.


10 example of a predefined function in a c?

1. Cat2. Cake3. Closet4. Coffin5. Cuckoon6. Cukoo Clock7. Clock8. Case9. Card10. ClothesThere we go, then things starting with C, if that is what you were asking for, but if its not, i would make your question more understandable, maybe change some words.Bye x


What is the definition of searching and sorting vb?

There is no special definition for VB; it is the same as in any other programming language - and the definition is similar to the commonly used definitions (i.e., outside of computer programming). Something like this: Search: try to find information. Sort: Reorganize data items in such a way that each data item is larger than the one before it.


In c plus plus Who tells the compiler that a specific class will be declared later in the program?

A forward declaration. However forward declarations can only be used when the class is used as a pointer or reference prior to its definition, otherwise it must be defined before it is used. class A; // forward declaration class B { A& data; // reference to class that has yet to be defined }; class A {}; // definition


What is the function that eliminates the need to place the function definition before all calls to the function?

A forward declaration. In all statically typed languages (such as C++), all types must be declared before they can be used. A function is a type (the return value defines its type), but the compiler only needs to know how the function is called, not how it is implemented, so the function definition does not need to be visible to the compiler before the function can be called. The definition can actually be placed in another translation unit entirely. Note that a function definition is also a function declaration. Forward declarations make it possible for two functions to be dependent upon each other. A function declaration includes the return type, the name of the function and its argument types. The formal names of a function's arguments are not required in it's declaration, they are only required in its definition. A function's signature is the same as its declaration but excludes the return type. All calls to a function must match its signature. If the return type is used, it must be assigned to a type that is covariant with the declared type. Function declarations are typically placed in header files. By including the header in every translation unit that uses the function, we ensure the function's declaration is consistent across all translation units. If the function is defined in the same header it is declared, then it must also be declared inline. Multiple definitions of the same function are permitted provided they are token-for-token identical, thereby adhering to the one definition rule (ODR).