Home » C solved programs » C - Number system conversion programs

C program to convert number from Decimal to Binary

In this program, we will read an integer number in Decimal and converts it into Binary Number System. This program is for Decimal to Binary Conversion in C.

The logic behind to implement this program - Get remainder using modulus operator by 2 and store it into an array then divide number by 2, repeat this process till given number is greater than 0. Because 2 is the base of Binary Number System.

For more details Learn: Computer Number System and its conversions.

Decimal to Binary Conversion using C program

/*C program to convert number from decimal to binary*/
#include <stdio.h>
int main()
    int     number,cnt,i;
    int     bin[32];
    printf("Enter decimal number: ");
    cnt=0;              /*initialize index to zero*/
    /*print value in reverse order*/
    printf("Binary value is: ");
    for(i=(cnt-1); i>=0;i--)
    return 0;


Enter decimal number: 545
Binary value is: 1000100001

Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com (2015-2018), Some rights reserved.