Integer's digits. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Integer's digits.

I have to write a program (in C++) in wich I have to multiplicate every digit of a "n" number by an "x" number. How do I get the digits of the "n" number? For example: int n; cin >> n; (let's suppose n = 12) How do I get 12's digits?

13th Dec 2017, 6:27 PM
CuriousCI
CuriousCI - avatar
1 Answer
+ 1
Convert to string, split string, convert characters back to int.
13th Dec 2017, 6:30 PM
1of3
1of3 - avatar