codinasion-archive / codinasion-monorepo

Community Monorepo
https://codinasion.org
MIT License
52 stars 168 forks source link

[Program]: Write a Swift program to convert octal to binary #3411

Open harshraj8843 opened 1 year ago

harshraj8843 commented 1 year ago

Description

Write a Swift program to convert octal to binary

Octal is a base-8 number system. It uses only eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. The digits are called octits. An octit is the smallest unit of information in a computer. An octit can be used to represent a single value, such as 0, 1, 2, 3, 4, 5, 6, or 7, or it can be used to represent a single state, such as on or off.

Binary is a base-2 number system. It uses only two digits: 0 and 1. The digits are called bits. A bit is the smallest unit of information in a computer. A bit can be either 0 or 1. A bit can be used to represent a single value, such as 0 or 1, or it can be used to represent a single state, such as on or off.

To convert an octal number to binary, we can use the following algorithm:

  1. Convert the octal number to decimal.
  2. Convert the decimal number to binary.
Input  : 12
Output : 1010
How to contribute - Save the solution in `program/program/convert-octal-to-binary/program/ConvertOctalToBinary.swift` file
akshithagunupati commented 10 months ago

!assign