0
Is there any difference between writing:
1) int x = 5; And 2) int x; x = 5;
3 Answers
+ 29
the same result, but first looks better.
@Pixie shouldn't D+I be in first var?
+ 12
Both are same
2)is Declaration and Initialisation done separately.
1)is Declaration+Initialisation
+ 2
The first way sets the value of the variable immediately and the second way sets it in the next line.
If you do the second way then always make sure that you set a value to the variable, like you did in the second line, else the variable won't have a value and will give you an error.



