question regarding integer declaration. i would appreciate any help. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

question regarding integer declaration. i would appreciate any help.

i have seen this question in while playing a challenge but i have even tried the code and is not running plz explain me if this code is executable or not https://code.sololearn.com/cr9VVH7MJiDn/?ref=app

15th Apr 2017, 5:25 PM
shobhit
shobhit - avatar
7 Answers
+ 21
The ternary operation implies that, if a and b are equal, then b will be 22, else b will be 33. But b is not initialized here. So you can't compare if a==b or not.
15th Apr 2017, 5:35 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 14
It doesn't compile because you didn't assign a value to b before the shortened if/else statement. You have to initialize b before you use it here.
15th Apr 2017, 5:32 PM
Tashi N
Tashi N - avatar
+ 13
Give some value to b also, then try the condition with new variable c
15th Apr 2017, 5:37 PM
Sachin Artani
Sachin Artani - avatar
+ 12
Oh man, put the variable b above c. You cannot use a variable before defining it. POP follows top to bottom approach so first initialise a, then b, then c.
15th Apr 2017, 5:41 PM
Sachin Artani
Sachin Artani - avatar
+ 3
thnx tash & shamima
15th Apr 2017, 5:36 PM
shobhit
shobhit - avatar
+ 2
can u plz send an example of how to do it.
15th Apr 2017, 5:35 PM
shobhit
shobhit - avatar
+ 2
i m trying but still getting similar result https://code.sololearn.com/cr9VVH7MJiDn/?ref=app
15th Apr 2017, 5:39 PM
shobhit
shobhit - avatar