Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
173 views

C Program To Convert Number From Decimal To Binary, Decimal To Binary Conversion - IncludeHelp

jkd

Uploaded by

gds
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
173 views

C Program To Convert Number From Decimal To Binary, Decimal To Binary Conversion - IncludeHelp

jkd

Uploaded by

gds
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

4/26/2018 C program to convert number from Decimal to Binary, Decimal to Binary Conversion - IncludeHelp

HOME ▼

c c++ java data structure python javascript css ajax pl/sql php puzzles c programs c++ programs
java programs

Custom Search

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

C program to convert number from Decimal to


Binary

Put Ads on your blog with


Adsense

LEARN MORE

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


http://www.includehelp.com/c-programs/c-program-to-convert-number-from-decimal-to-binary.aspx 1/5
4/26/2018 C program to convert number from Decimal to Binary, Decimal to Binary Conversion - IncludeHelp

/*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: ");


scanf("%d",&number);

cnt=0; /*initialize index to zero*/


while(number>0)
{
bin[cnt]=number%2;
number=number/2;
cnt++;
}

/*print value in reverse order*/


printf("Binary value is: ");
for(i=(cnt-1); i>=0;i--)
printf("%d",bin[i]);

return 0;
}

Output

Enter decimal number: 545


Binary value is: 1000100001

Cheap & Quality used cars


Buy low price used cars
directly from Japan,view our
stock, sign up now!

http://www.includehelp.com/c-programs/c-program-to-convert-number-from-decimal-to-binary.aspx 2/5
4/26/2018 C program to convert number from Decimal to Binary, Decimal to Binary Conversion - IncludeHelp

You may also be interested in...

c/c++ tips and tricks...


C - Fastest way to copy two bytes integer number (short int) into byte bu er.
C - Pre-Increment is faster than post-increment.
C - How to create delay function according to program need?
Why should we use 'f' with oat literal in C?
Replacing a part of string in C.
Comparing xed number of characters of two strings in C language.
A safest way to check value using 'Equal To' (==) operator in C.
Check EVEN or ODD without using Modulus (%) Operator in C.
How can we use a single byte to store 8 values in C?
A funny trick to use C++ in C language program.
An amazing trick to print maximum value of an unsigned integer in C.

Buy Used Cars online


Shipping to Zambia from
Japan. Secure payment.
Huge stock.

most viewed pages...

http://www.includehelp.com/c-programs/c-program-to-convert-number-from-decimal-to-binary.aspx 3/5
4/26/2018 C program to convert number from Decimal to Binary, Decimal to Binary Conversion - IncludeHelp

C language solved programs


C++ language solved programs
C switch case programs
Basic Input, Output C programs
In x to post x conversion using stack in C
C programming Aptitude Que. and Ans.
Core java programs
Computer number systems & conversions
Java solved programs
C++ le handling programs
Recursion programs in C
More pages...

featured posts...
Di erence between %d and %i in C language.
Di erence between printf and sprintf in C language.
Di erence between Sentinel and Counter Controlled loop in C language.
Di erence between Entry Control and Exit Control loop in C language.
Di erence between Unary and Binary Operators in C language.
Di erence between = (Assignment) and == (Equal to) Operators in C language.
Di erence between & (Address Of) and && (Logical AND) Operators in C language.
Di erence between Local and Global variables in C.

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions

http://www.includehelp.com/c-programs/c-program-to-convert-number-from-decimal-to-binary.aspx 4/5
4/26/2018 C program to convert number from Decimal to Binary, Decimal to Binary Conversion - IncludeHelp

0 Comments www.includehelp.com 
1 Login

Sort by Newest
 Recommend ⤤ Share

Start the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

Name

Be the first to comment.

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd 🔒 Privacy

# About # Advertise # Contact # Feedback


# Internship # Certi cates # Jobs
# Personal blogs # Guest posting # Subscribe

Keywords (like Linux, Java, Oracle etc) used in this website are the trademarks of their respective owners/company. This
website is not a liated to any company. The tutorials are designed by includehelp Team with the help of well known
books and other online resources. These Tutorials are free for all, for learning purposes only. Enjoy learning:)
Copyright © 2015 - 2017. All Rights Reserved.

http://www.includehelp.com/c-programs/c-program-to-convert-number-from-decimal-to-binary.aspx 5/5

You might also like