## Question Reference

C Home

### C Inbuilt Functions

C String FunctionsC Math Functions

### C Interview Programs

C Common ProgramsC Array ProgramsC Converter ProgramsC Star Patterns ProgramC Number Patterns ProgramC Alphabet Patterns Program

ASCII Table

# C Program to Converter a Binary to Decimal

Last Updated:

## Converter a Number from Binary to Decimal

In the following example, we will convert a Binary number (1000001) to a Decimal number (65).

Tips: It is recommended to use our online Binary to Decimal converter for better understanding.

### Example

C Compiler
#include <stdio.h> #include <math.h>; int main() { int num = 1000001; int arr[50]; int i = -1, j, total = 0; while(num != 0) { i++; arr[i] = num % 10; num = num / 10; } for(j=i; j>=0; j--) total += (arr[j] * pow(2, j)); printf("Decimal number of 1000001 (binary) is %d", total); return 0; }

## Converter any Given Binary Number to Decimal Number

In the following example, we will convert any given binary number to a decimal number.

### Example

C Compiler
#include <stdio.h> #include <math.h>; int main() { int num, copyNum, arr[50]; int i = -1, j, total = 0; printf("Enter a Binary Number: "); scanf("%d", &num); copyNum = num; while(copyNum != 0) { i++; arr[i] = copyNum % 10; copyNum = copyNum / 10; } for(j=i; j>=0; j--) total += (arr[j] * pow(2, j)); printf("Decimal number of %d (binary) is %d", num, total); return 0; }