Binary to Decimal | Conversion | While Loop | Lecture #65 #cprogramming #coding #c #hindi

preview_player
Показать описание
Binary to Decimal Conversion
Binary to decimal conversion is the process of converting a binary number (a number represented in base 2, using only 0s and 1s) to its decimal equivalent (a number represented in base 10).
How it Works
To convert a binary number to decimal, you need to multiply each binary digit (or bit) by the corresponding power of 2 and then sum the results.
Here's a step-by-step breakdown:
Start from the right: Begin with the rightmost bit (the least significant bit) of the binary number.
Multiply by the power of 2: Multiply each bit by the corresponding power of 2, starting from 2^0 (which is 1) for the rightmost bit.
Add the results: Sum the results of the multiplications.
Repeat for each bit: Move to the next bit to the left and repeat the process until you've processed all bits.
Example
Let's convert the binary number 1011 to decimal:
Start from the right: 1 (rightmost bit)
Multiply by the power of 2: 1 × 2^0 = 1
Add the result: 1
Move to the next bit: 1
Multiply by the power of 2: 1 × 2^1 = 2
Add the result: 1 + 2 = 3
Move to the next bit: 0
Multiply by the power of 2: 0 × 2^2 = 0
Add the result: 3 + 0 = 3
Move to the next bit: 1 (leftmost bit)
Multiply by the power of 2: 1 × 2^3 = 8
Add the result: 3 + 8 = 11
Therefore, the binary number 1011 is equal to the decimal number 11.
#code
#coding #logical #conversion #whileloop #hindi #cprogramming #binary #decimals
Рекомендации по теме
join shbcf.ru