0

Can we use two variables in single line by putting comma and assigning them values?

13th Nov 2020, 6:35 AM
Laiba Noor
3 Réponses
+ 4
Yes, this should work fine. int a = 10, b = 20;
13th Nov 2020, 6:50 AM
Avinesh
Avinesh - avatar
0
Actually I tried but it does not work.Thanks for replying.
13th Nov 2020, 6:52 AM
Laiba Noor
0
Yes. But both variable should be same data type. int a=10,b=20; If you're using different data type separate them by semicolon " ; " int a=10 ; float b=20.5; Are you clear now?
13th Nov 2020, 8:37 AM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar