0

# What are octal integer constants and hexadecimal integer constants?

Also rules to write them

8/22/2018 7:31:19 AM

Sandy

+7

if you want algorithm to convert integers to octal then it would be like this : while(num > 0) { cout << num % 8; num /= 8; } for integers to hex int num = 235458; vector<char> myVec; while(num > 0) { int hex = num % 16; if(hex > 9) myVec.push_back((char)(hex - 10 + 'A')); else myVec.push_back((char)(hex + 48)); num /= 16; } for(int i = myVec.size() - 1; i >= 0; i--) cout << myVec.at(i);

+2

printf("%d\n",010); /* 8 */ printf("%d\n",0x10); /* 16 */

+2

octal begins with 0 hex begins with 0x

+2

13 is 015 in octal 0x0d in hex

+1

I was hesitated to see that you wrote octal & hexadecimal integer constants, are you asking how to create a constant in octal & hexadecimal, or how to write an integer in a certain base (octal & hexadecimal)? Also you need to specify which language in question tags.

0

please explain rule to write them as such

0

im asking in c++. iwant t know how to write random integers like 13 in their format

0

please tel the algorithm to get it