what is the difference between declaration ,defenetion and
initialization of a variable?




Answers were Sorted based on User's Feedback



what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / gg

As i know.....
Definition is one which allocates memory.
Ex: int x;

Declaration never occupy any memory space.
Ex:Function prototype declarations such as....
int func(int,int);

Initialization: If any variable assigned with some value at
time definition itself is called initialization.
Ex:int x=0;

Is This Answer Correct ?    35 Yes 7 No

what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / shabeer v c

A good example to illustrate this Question ges like this:

Whenever we apply for a job the company declares that we
have been selected. Similarly we declare a variable like

int emp;
(here emp behaves as an employee).

Then he will be assigned with a initial salary which
will be incremented in course of time period or on
experience basis.
Similarly the variable int is assigned a initial
value.
i.e int emp=20;
(value can be changed in between program)

The employee is now identified by his post, which can
define his status in the company.
Same way the variable is also defined in the
program.
ie. int emp;

Is This Answer Correct ?    16 Yes 3 No

what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / siddiqui mohd. faisal

declaration : int a;
declaration means here a is declared as integer variable
initialization : int a = 5;
initialization is whatever you have declared give that
variable some value
definition : int a;
definition is whatever variable you have declared give it's
datatype as here a is declared as integer variable

Is This Answer Correct ?    32 Yes 21 No




what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / nirmal kumar tailor

declaration means you declare variable.
ex: int a;
defination means this integer type a variable take 2 byte
memory space.
initialization means we initialize the value of integer a
variable type.
ex: int a=2;
in declaration we declare variable and variable type , in
initialization we define the value and in defination we
define the type of variable.

Is This Answer Correct ?    23 Yes 16 No

what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / harshit

there is no practical such as declaration its in theory only
the only practical application is :

int a; //defination
a=10; //intialization

this is a normal thing we do,,,now

somemethod()
{
int a;//defination
}


main()
{
extern int a;//declaration
a=10//intialization
}

here we declare that there is a variable "a" somewhere
n this is the only use of declaration ...
to best of my knowledge...
plz suggest if someone kno better

Is This Answer Correct ?    3 Yes 2 No

what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / prakash

Declaration: int a;(does not allocate memory)
Initialisation: a=5;(value is assigned for 'a')
Definition: int a=5;(allocates memory)

Is This Answer Correct ?    5 Yes 6 No

what is the difference between declaration ,defenetion and initialization of a variable?..

Answer / sakthi sudhan

declaration : int a;
declaration means here a is declared as integer variable
initialization : int a = 5;
initialization is whatever you have declared give that
variable some value
definition : int a;
definition is whatever variable you have declared give it's
datatype as here a is declared as integer variable

Is This Answer Correct ?    1 Yes 8 No

Post New Answer



More C Interview Questions

Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.

5 Answers  


what is printf

5 Answers   Satyam, MVSR,


what is answer for perfect number????????????????

1 Answers  


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

0 Answers   HCL,


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

0 Answers   Mind Tree,






What are advantages and disadvantages of recursive calling ?

12 Answers   HP, College School Exams Tests, Jyoti Ltd, Sage, Wipro, Evolving Systems,


1)what are limitations for recursive function? 2)write a program to read a text file and count the number of characters in the text file

1 Answers  


write a c program to remove all the duplicate characters in a string and replace with single character? ex:-input- AAABBBCCC output- ABC

2 Answers   HCL,


Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i; Output of i after executing the program

5 Answers   Mascot,


a=(1,2,3); b=1,2,3; c=1,(2,3); d=(1,2),3; what's the value of 'a','b','c','d'

2 Answers  


4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it. i have done maximum par but i m findind problem in the commented area. please help...

3 Answers  


How to swap 3 numbers without using 4th variable?

5 Answers  






Categories