Write your question here.
Hello, I am new to the community. I want to ask a question about my code. I want to return a vector from my function dec2Bin. In main, when I call this function, I only get one value inside my vector. I don't know what is wrong with it, can someone help me please. This is the code I have
std::vector< unsignedint > dec2Bin( unsignedint n ) {
if( n < 2 ) return {n} ; // return a vector containing the one element 0 or 1
else {
std::vector< unsignedint > vec = dec2Bin(n/2) ; // get the higher order bits
vec.push_back(n%2) ; // add the least significant bit at the end
return vec ;
}
}