0
What are octal integer constants and hexadecimal integer constants?
Also rules to write them
5 Respuestas
+ 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);
+ 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