def DecimalOctal(num):
          octal = [0] * 100
          # counter for octal number array
          i = 0
          while (num != 0):
              # store remainder in octal array
              octal[i] = num % 8
              num = int(num / 8)
              i += 1
          # print octal number array in reverse order
          for j in range(i - 1, -1, -1):
              print(octal[j], end='')
      # take inputs
      num = int(input('Enter a decimal number: '))
      # calling function and display result
      print('Octal value: ', end='')
      DecimalOctal(num)
      
      Python language logo

      Decimal to Octal

      beginner
      basicMaths

      Python Program to Convert Decimal to Octal

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.