+ 2

Im just a stupied question: declaring runtime

Is there a difference between the runtime of declaring a variable and give it a value in the same line (int x = 5;), and declare a variable and give it a value in another row (int x; x=5;)?

13th Feb 2017, 10:44 AM
‫איתן וייס‬‎
‫איתן וייס‬‎ - avatar
3 Respuestas
+ 10
There is no difference , Because you declared x as a variable and in variables you can declare the variable in a line and then assign a value to it in another line or you can declare it and assign value to it in the same line :)
13th Feb 2017, 2:29 PM
Hassan Amr
Hassan Amr - avatar
+ 6
doesn't matter but if you had to declare 4-5 variables in that case declaring on another line is easy. int a,b,c,d,e; a = 0; b = 1; like this.
14th Feb 2017, 1:26 AM
Ram chandra Giri
Ram chandra Giri - avatar
+ 1
thanks!
13th Feb 2017, 2:34 PM
‫איתן וייס‬‎
‫איתן וייס‬‎ - avatar