GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Concepts  >  Data Structures
Go To First  |  Previous Question  |  Next Question 
 Data Structures  |  Question 178 of 198    Print  
What is the difference between declaration and definition?

  
Total Answers and Comments: 3 Last Update: May 09, 2008     Asked by: Kashif 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 13, 2007 13:09:59   #1  
Xing        

RE: What is the difference between declaration and def...
In case of C Functions.

Declaration: When we write the prototype of the function before using it, this is called function declaration.

Definition: When we define code for the function with the function name itself, it is called function definition.

 
Is this answer useful? Yes | No
December 28, 2007 01:36:59   #2  
manishmodgil Member Since: July 2006   Contribution: 15    

RE: What is the difference between declaration and definition?
DECLARATION : declaration only creates the variable name and nothing exists against it. i.e no memory space is consumed.

eg. extern a;

DEFINITION : definition declares as well as assigns some value to the variable.

eg.  int a;

even though we are not mentioning any value default value is provided by the C compiler.

eg. int a=10;

 
Is this answer useful? Yes | No
May 09, 2008 08:32:13   #3  
jontyrodes Member Since: May 2008   Contribution: 1    

RE: What is the difference between declaration and definition?

Definition
int * i
i is definitionsince we can store a address without allocating memory
*i is definition since we can assign *i = 4 ;

Definition
char *c
c is definition since it can store a address of a character
*c is definition since it can store a character
Now, c is a declaration for storing a string, now i need to allocate memory to store a string..

Comments anyone ???


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape