C C++ program to convert binary to decimal
Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C
C और C++ दोनों भाषाओं में महत्वपूर्ण अंतर क्या है जानने के लिए देखें—C vs C++
Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP
Flowchart to convert binary to decimal

C program to convert binary to decimal
#include<stdio.h>
int main()
{
int binary, decimal=0, digit, base=1;
printf("Enter binary number: ");
scanf("%d",&binary);
while(binary!=0)
{
digit=binary%10;
decimal=digit*base+decimal;
base=base*2;
binary=binary/10;
}
printf("Decimal number = %d",decimal);
return 0;
}
C++ program to convert binary to decimal
#include<iostream>
using namespace std;
int main()
{
int binary, decimal=0, digit, base=1;
cout<<"Enter binary number: ";
cin>>binary;
while(binary!=0)
{
digit=binary%10;
decimal=digit*base+decimal;
base=base*2;
binary=binary/10;
}
cout<<"Decimal number = "<<decimal;
return 0;
}
Output of C C++ program to convert binary to decimal
Enter binary number: 110100 Decimal number = 52
Enter binary number: 1001110 Decimal number = 78
More looping and Iteration programs in C and C++
- Generate series of natural numbers (while, for, do while)
- Generate series of natural numbers and their sum
- Generate series of odd numbers and find their sum
- Generate series of even numbers and find their sum
- Generate table of given number
- Find factorial of given number
- Find power of given number
- Generate multiplication table of given number
- HCF and LCM of two numbers
- Generating Fibonacci series
- Checking prime number
- Generating series of prime numbers
- Sum of digits of given number
- Reverse of digits of given number
- Checking palindrome number
- Checking Armstrong number
- Generating series of Armstrong numbers
- Convert binary to decimal