Why results are different ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
5th Jul 2019, 1:42 AM
RITIK KUMAR
RITIK KUMAR - avatar
5 Answers
+ 5
When you write x=1,2,3; the compiler understands: * assign 1 to x * assign 2 to nothing * assign 3 to nothing When you write int x=1,2,3; the compiler understands: * create a variable x and assign 1 to it * create a variable named 2 -> this is an invalid name -> it tells you that it expects an unqualified-id * create a variable named 3 -> this is an invalid name
5th Jul 2019, 2:15 AM
Paul
+ 7
RITIK KUMAR this happens because when you write int x=1,2,3; the compiler treats 2 and 3 as variables but we know that variable name can't start with a number. So the program gives an error.
5th Jul 2019, 2:43 AM
Manoj
Manoj - avatar
+ 3
Thanks bro
5th Jul 2019, 2:34 AM
Vijay Sai
Vijay Sai - avatar
+ 3
Thanks LIOÑ
5th Jul 2019, 2:58 AM
RITIK KUMAR
RITIK KUMAR - avatar
+ 2
Thanks bro
5th Jul 2019, 2:18 AM
RITIK KUMAR
RITIK KUMAR - avatar