[SOLVED] How do I turn two variables like 1 and 2 into one variable 12. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[SOLVED] How do I turn two variables like 1 and 2 into one variable 12.

29th Jul 2020, 7:20 PM
bob
bob - avatar
4 Answers
+ 1
By Concatenating them. example int a = 1; int b = 2; int result = (int) (to_string(a) + to_string(b)) bob something like this.
29th Jul 2020, 7:32 PM
Rohit
+ 1
bob what language and have you an actual related question ? If so please post your code attempt here with somewhat clarity as to what the issue appears to be. Thanks and happy coding.
29th Jul 2020, 7:32 PM
BroFar
BroFar - avatar
0
Use concatination var a = "1" ; var b = "2" ; var c = a+b ; Console.log(c) ; //-> 12
29th Jul 2020, 7:33 PM
Divya Mohan
Divya Mohan - avatar
0
var a = 1 ; var b = 2; var c = a+""+b ;
29th Jul 2020, 7:38 PM
Divya Mohan
Divya Mohan - avatar