0
Guys what are the various ways to convert any integer values into an integer array...?
10 Respostas
+ 2
try this way
https://code.sololearn.com/cC7E56Jk0Uz1/?ref=app
+ 1
c++:
#include <array>
int toConvert;
array<int> arr = { toConvert };
java:
int toConvert;
int[] arr = { toConvert };
0
we can use % to get individual elements and than save in a array
0
@Timom i want to store that no. individually in array.. like 125 --> 1,2,5
0
Ok, try doing that yourself with c++, it's fun. Hint: use modulo and division to get the digits. Try it first with 3 digits, then with n digits (hint: vector) and then make the whole thing a template function. I'll do the same thing. When you're done, I'll make my code public and we can compare.
0
Done.
0
Your solution prints the digits in reverse order, pratheek shenoy k. ) :
0
You need pow of the <math> header for the last 2 steps, Gaurav.
0
yes it gives in reverse order, we can access the array as we want by changing the for loop
0
Yes, ok. I thought you didn't test it and that this would be a semantic error. Sorry.