• 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

Decimal to Binary

C Programming 569 views
#include<stdio.h>

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


/* Output */
Welcome to Decimal to Binary converter
Enter a decimal number: 5
Binary value is: 101

Decimal and Binary

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