Answer to Question #259622 in Algorithms for liza

Question #259622

Suppose N is a decimal number, where N represents the last 4 digits of your student

id.

i) Convert N to binary.

ii) Convert N to hexadecimal


1
Expert's answer
2021-11-03T17:31:12-0400
Start
   Declare integer varaible N
   Declare array integer binary[40]   
   Declare integer varaible index = 0    
   Read N
   while decimal > 0 do   
       Set binary[index] = decimal mod 2
       Set index=index+1
       Set decimal = decimal/2
   End while
   for i = index-1 to  0 Step -1
       print binary[i]
   end for
   Declare integer variable rem       
   Declare string variable  result=""
   Declare char array hex[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}
   While num>0 do
       rem=num mod 16
       result=hex[rem]+result
       num=num/16
   End while
   print result
Stop

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS