what is the difference between declaration and definition
of a variable or function ?
Answers were Sorted based on User's Feedback
Answer / suman_kotte
declares a function, but that does not define it.
declaration describes whether the function consist
arguments or not and also it will return a value or not.
definition must be as per the function declaration that was
declared rearlier.it will for the out put of that function.
ex;
main()
{
int a=1,b=2;
void sum(int , int );//declaration
sum(a,b);
}
void sum(int x, int y)//definition
{
printf("%d",x+y);
}
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / michael scofield
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;
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / ashu_deepu
i will like to add 1 thing abt d variabes.
declaring a variable means
int deepu; //it is declaration
defining means assigning value to the variable.
eg: int deepu=2018; //it is definition
| Is This Answer Correct ? | 4 Yes | 5 No |
An array name contains base address of the array. Can we change the base address of the array?
write a program to remove occurrences the word from entered text?
Explain how many levels deep can include files be nested?
what is the associativity of bitwise OR operator?
How to swap two values using a single variable ? condition: Not to use Array and Pointer ?
How do you override a defined macro?
the operator for exponencation is a.** b.^ c.% d.not available
What is the return type of sizeof?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What is sizeof in c?
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250
out put of printf(“%d”,printf(ram));