94.6k views
4 votes
How to combine two integers​

User Jezbers
by
7.9k points

1 Answer

7 votes

The simplest approach to do this is:

Convert both numbers to string

Concatenate both strings into one, as this is comparatively easy

Convert this concatenated string back to integer

Explanation:

Given two integers n1 and n2, the task is to concatenate these two integers into one integer.

Example:

Input: n1 = 12, n2 = 34

Output: 1234

Input: n1 = 1, n2 = 93

Output: 193

User Greg Zuber
by
8.1k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories