Question: AT&T 3:34 PM 57% 1.2 Convert decimal to binary, decimal to hesx This function inputs a positive integer in decimal, and outputs an array (vector)
AT&T 3:34 PM 57% 1.2 Convert decimal to binary, decimal to hesx This function inputs a positive integer in decimal, and outputs an array (vector) with digits in aay base from 2 through 16 ist dec.to basest,t base, atd::vectorcchar> & digits) digits.clearO if ((base 2) II (base16)) return 1: if (a ) returmn 1 ail / fail digits pashback(alphamn[o] retura 0 char c -alphasun[ren): digits-puh back(e) a base; std: reverseldigits.begia), digits.end)): II reverse the digits . Note that the output vector is 'char Bot "iat' because the digits are alphaumerie The funetion returm type is 'int" not void'beeamse we test for bad inputs: the function r 0 for success and 1 for Eailure The output ckmeuts are ordered so that if we print as follows, we et the dizits in the base for (int i0; & digits) digits.clearO if ((base 2) II (base16)) return 1: if (a ) returmn 1 ail / fail digits pashback(alphamn[o] retura 0 char c -alphasun[ren): digits-puh back(e) a base; std: reverseldigits.begia), digits.end)): II reverse the digits . Note that the output vector is 'char Bot "iat' because the digits are alphaumerie The funetion returm type is 'int" not void'beeamse we test for bad inputs: the function r 0 for success and 1 for Eailure The output ckmeuts are ordered so that if we print as follows, we et the dizits in the base for (int i0;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
