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 |
How many types of operator or there in c?
Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.
which of 'arrays' or 'pointers' are faster?
print the pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 if n=5
what are # pragma staments?
What is the difference between the expression “++a” and “a++”?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
which operator is known as dummy operator in c?
What Is The Difference Between Null And Void Pointer?
I have seen function declarations that look like this
How was c created?
write a c program to find the roots of a quadratic equation ax2 + bx + c = 0
11 Answers CSC, St Marys, TATA,