100 002
Assignments Done
98.3%
Successfully Done
In June 2021

# Answer to Question #39660 in C++ for Theodore

Question #39660
Hello, I am studying C++ and fairly new at the language, I am trying to get a better understanding on how the following code works:
#define MAX 1000
int main(){
int temp;
long int i=0,j=0;
cout &lt;&lt; &quot;Enter any number any binary number: &quot;;
cin &gt;&gt; binaryNumber;
while(binaryNumber[i])
{
binaryNumber[i] = static_cast&lt;int&gt;(binaryNumber[i]) -48;
++i;
}
--i;
while(i-2&gt;=0){
temp = binaryNumber[i-3] * 8 + binaryNumber[i-2] * 4 + binaryNumber[i-1] * 2 + binaryNumber[i] ;
if(temp &gt; 9)
else
i=i-4;
}
if(i ==1)
hexaDecimal[j] = binaryNumber[i-1] * 2 + binaryNumber[i] + 48 ;
else if(i==0)
hexaDecimal[j] = binaryNumber[i] + 48 ;
else
--j;
cout &lt;&lt; &quot;Equivalent hexadecimal value: &quot;;
while(j&gt;=0){
}
0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!