answersLogoWhite

0


Best Answer

declaration examples:

int main (void);

extern int somevariable;

definition examples:

int main (void) { puts ("Hello world"); return 0; }

int somevariable;

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between declaration and a definition in C with small example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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 an example and a definition?

An example is where someone asks you what something is you show them instead of tell them. A definition is where you explain what something is.


When variable in c gets memory After declaration or initialization?

Definition. Example: extern int x1; /* declaration */ int x2; /* definition */ int x3= 2; /* definition with initialization */


What is the definition of difference in math?

The difference, in a subtraction sum, is the answer to the sum. For example, the difference between 6 and 4 is equal to 2. 6 - 4 = 2.


What is Variable declaration and variable initialization?

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


What is the difference between Declaration and Statement?

A declaration introduces a new entity or concept, specifying its type and name, without necessarily assigning a value. A statement, on the other hand, is an action or command that carries out a specific task or operation, such as assigning a value or controlling the flow of a program.


What is the definition for variation?

Any difference between two indivisuals of the same species For example: Eye colour, Hair colour etc is called Variation


What is the difference between has and have and give an example?

the difference between has and have is that you use has in sentences with : ( she , he and it ) for example : she has a book . but you use have in sentences with : ( I , you , we and they ) for example : you have a book , I have a book .


Difference between the definition and declaration of a variable in c?

definition defines the memory area ( allocates the memory ) for the variable and the declaration tells about the signature of the variable ( type and size to be considered). definition occures once through the program( memory is allocated once ), but the declaration can occur many times.OR For a variable, the definition is the statement that actually allocates memory. For example, the statement:long int var;is a definition. On the other hand, an extern reference to the same variable:extern long int var;is a declaration, since this statement doesn't cause any memory to be allocated. Here's another example of a declaration:typedef MyType short;Second AnswerDeclaration can come only once and definition can come many times in the program.Let's take an example,Line 1: #includeLine 2:Line 3: void main()Line 4: {Line 5: int x; //declarationLine 6:Line 7: x=10; //definitionLine 8: }In the above program, on the line 5 what appears is declaration and on line 7 the definition is there.Now if we declare the variable x again in the program we will get the error saying that the variable is already declared.Whereas if we assign some new value to variable x, say 20i.e.x=20;this is totally fine and we can assign any number of values in the same program. This means that the declaration is only one throughout the program but definitions can be many.


Difference between eg and ie?

example given......in example


Difference between object declaration and object creation?

Declaration of the object involves only creating the reference variable to the object. Example: class SampleClass{ } Object Declaration: SampleClass obj1; Object Creation: Creating an object involves use of new keyword and actually allocating memory for that object. SampleClass obj2 = new SampleClass ();


What is the difference between sample and example?

Definition of example is one (as an item or incident) that is representative of all of a group or type.Similarly, a definition of sample is1) a representative part or a single item from a larger whole or group especially when presented for inspection or shown as evidence of quality.Another definition of sample is2) a finite part of a statistical population whose properties are studied to gain information about the whole.The difference being that an example is typically one item and a sample is one or more items.