• Free Template
  • Programming
    • Coding Guides
    • Articles
  • Tips & Tricks
  • Technology
  • What's Hot

c Examples

  • Introduction
  • Hello World
  • Calculation
  • Greatest Number
  • Armstrong Number
  • Multiplication Table
  • Perfect Number
  • Prime Number
  • Even Odd
  • Factorial
  • Fibonacci Series
  • Palindrome Number
  • Palindrome String
  • Temperature Converter
  • Recursive Factorial
  • Numeric Pyramid
  • Decimal to Binary
  • Decimal to Octal
  • Decimal to Hex
  • Binary to Decimal
  • Array Sum
  • Two Array Sum
  • LCM
  • GCD
  • Leap Year
  • Matrix Addition
  • Matrix Multiplication
  • Swapping
  • Binary Search
  • Linear Search
  • Bubble Sort
  • Insertion Sort
  • Selection Sort
  • Quick Sort
  • Merge Sort
  • Heap Sort
  • Write File
  • Read File
  • Copy File
  • Delete File
  • Singly Linked list
  • Doubly Linked list
  • Stack
  • Queue
  • Circular Queue
  • Binary Tree
  • Run Linux Command
  • Change Case

Apr 16, 2020

Binary to Decimal

C Programming 721 views
#include<stdio.h>

int main() {
	int decimal = 0, binary, i = 1, reminder;
	printf("Welcome to Binary to Decimal converter\n");
	printf("Enter a binary number:\n");
	scanf("%d",&binary);
	while(binary != 0) {
		reminder = binary % 10;
		decimal += reminder * i;
		i *= 2;
		binary /= 10;
	}
	printf("Decimal value is: %d\n",decimal);
	return 0;
}


/* Output */
Welcome to Binary to Decimal converter
Enter a binary number:
1000

Decimal value is: 8

Binary and Decimal

Tags:
cc languagec programmingc coding for binary to decimal conversationbinary to decimal converter in cgeekboots tutorialgeekboots c programmingc code for binary to decimal converter
Author: Geekboots
Share On
Geekboots © 2022 About UsContact UsTermsCookie PolicyPrivacySubmit Article