answersLogoWhite

0


Best Answer

A declaration and definition of a variable are nearly synonymous, especially as it is found in source code. However, the concepts are separate. The definition of a variable may include variable name, type, scope, operating range, and initial value(s). Program documentation includes only the definition of a variable; not the declaration. It defines the meaning and use of a variable. Whereas the declaration of a variable indicates to the compiler/interpreter that the name should be recognized as a variable. Understand that when the variable declaration is given in source code it may include the definition, though not always. In some languages a variable may be declared and then defined later as to type, operating range, et al.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is different between a definition and declaration of a variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Physics

What is the difference between indepedent and dependent variables?

In a science experiment, the independent variable is the one you change. For example: if you are doing an experiment on the impact of different types of soil on plant growth, the different types of soil would be your independent variable. The dependent variable is the outcome, or whatever the independent variable directly impacts. In this case, the dependent variable is the height of each plant.


What is the scientific definition of graph?

A diagram showing the relation between variable quantities, typically of two variables, each measured along one of a pair of axes at right angles.


What is the definition of idependent variable?

An independent variable is a part of an experiment that might change due to the outcome not being a desired result. The person conducting an experiment about how a medicine might affect a person, might change the number of people tested to gain more insight into the results. The independent variable in that situation would be the number of test subjects.


What is a sentence using dependent variable?

A dependent variable is something that is measured in an experiment each time the independent variable is changed in order to gage the relationship between the two, if any is in existence. For example, if the time taken for a ball to fall from different heights was being measured, the independent variable (thing beig changed) is the height, and the dependent variable (thing that changes because of the independent variable) is the time taken for the ball to hit the ground.


What is the definition of adhesion force?

Adhesion force is the force of attraction between molecules of different kind. Eg.adhesion force exists between the molecules of water and the molecules of its containing vessel.

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 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 */


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 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.


C programming language bsc it notes?

different between defining value definition section and defining value declaration section


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.


What is the difference between initialisation and definition in C programming?

Variable-declaration is: extern int x; extern double y; extern char a; Variable-definition is: int x; static double y; auto char a; Variable-definition with initialization is: int x = 1; static double y= 2.3; auto char a = 'w';


Difference between int a and extern int a. why the first one is definition while the second is declaration please explain?

The declaration 'int a' both declares the variable of 'a' and allocates memory for it. When you use 'extern' you are referring to a variable called 'a' that has its memory allocated in another module. The actual variable 'a' is not in the same compilation unit as the current one being compiled. Where the variable 'a' is located is resolved by the linker. When using 'extern' you state your intent to use a variable called 'a', but it doesn't reserve any memory for it in the current module.


What is the function definition?

function is the relationship between independent variable & dependent variable i.e. F:R-R


What is the difference between Declaration and Assignment?

Declaration is basically defining data type and length and assignment is to assign the value. Below is the declaration -- var a integer /* this means we are declaring a variable a as integer data type */ a= 5 /* this is assignment,we are assigning 5 to variable a */


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 */