Question: What is the difference between declaration and definition of a variable?
Answer: Declaration specifies the properties of a variable. For example:
int x; /* x is an integer */ int roll_no[]; /* roll_no is an array of integers */
Definition declares a variable and causes the storage to be allocated. For example:
int x = 10; /* x is declared as an integer and allocated space and initialized to 10 */ int roll_no[100]; /* roll_no is declared as an array of integers, allocated space for 100 integers */
Sanfoundry Global Education & Learning Series – 1000 C Tutorials.
advertisement
advertisement
If you wish to look at all C Tutorials, go to C Tutorials.
Next Steps:
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Related Posts:
- Apply for C Internship
- Practice BCA MCQs
- Buy Computer Science Books
- Watch Advanced C Programming Videos
- Buy C Books