program to convert int to int array c 2b 2b

Solutions on MaxInterview for program to convert int to int array c 2b 2b by the best coders in the world

showing results for - "program to convert int to int array c 2b 2b"
Paula
11 Jan 2019
1#include <iostream>
2#include <vector>
3using namespace std;
4
5vector <int> integerToArray(int x)
6{
7    vector <int> resultArray;
8    while (true)
9    {
10    resultArray.insert(resultArray.begin(), x%10);
11    x /= 10;
12    if(x == 0)
13        return resultArray;
14    }
15}
16
17int main()
18{
19    vector <int> temp = integerToArray(1234567);
20    for (auto const &element : temp)
21        cout << element << " " ;
22    return 0;
23}
24
25//outputs 1 2 3 4 5 6 7 
26