How to write a C Program to convert given decimal number into binary number in C Programming Language ?
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,j=0,rem;
clrscr();
printf("\nEnter the Decimal Number: ");
scanf("%d",&n);
while(n!=1)
{
rem=n%2;
printf("\n%d",rem);
a[j]=rem;
n=n/2;
printf("\n%d%d",a[j],n);
j++;
}
a[j]=1;
printf("\nBinary Number is: ");
for(i=j;i>=0;i--)
printf("%d",a[i]);
getch();
}
//OUTPUT:
//Enter the Decimal Number: 12
6 0
3 0
1 1
1 1
//Binary Number is: 1100
Learn More :
Number
- Find out the perfect number using c program
- Write a c program to find out H.C.F. of two numbers.
- Check the given number is armstrong number or not using c program.
- Write a c program to find largest among three numbers using conditional operator
- FIND OUT GENERIC ROOT OF A NUMBER - C PROGRAM.
- FIND PRIME FACTORS OF A NUMBER USING C PROGRAM
- How To Write a C program that generates two random numbers ?
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to perform math operations on two input whole numbers. The operations are:
- Write a C program to find maximum between three numbers ?
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program to Enter an ODD number between 1 and 49.
- C program acquires keyboard 10 numbers for each of these numbers to determine if it is a first issue, by printing immediately message should at the end, if none of the numbers you entered was a first issue, print an appropriate message.
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program to Find Random Number
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Find LCM and HCF Of Two Number -1
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Frequency Of A Number
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print Sum Of n Digit Number
- C Program To Reverse A Number
- C Program To Search A Number Inside The Array
given
- C Program To Find Week Day Of A Given Date
- Give me an integer and I will sum it with the previous natural numbers
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program to Check Given String is Palindrome or Not
- C Program That in a Given Natural Number x Insert Figure c at Position p
- Return the number of tokens given a command
- C Program reads in and spews out the attributes of a given .wav file.
- C Program Recursive function that searches for a given file in a given folder
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C program to display the transpose of given 3 X 3 matrix
Convert
- How To Write a C program that reads your first and last names and then converts them to upper-case and lower-case letters. The results will be printed to standard output console.
- C Program to Convert Text String to Binary
- C Program To Convert Decimal To Binary Using Recursion
- C Program To Convert Temperature In Celsius To Fahrenheit, Using Function
- C Program To Convert Temperature Into Celsius
- C Program to Convert Celsius to Fahrenheit temperature
- C Program to convert a string to upper case
- C Program Convert MIDI note to pitch
- C Program to Convert Celcius to Fahrenheit and vice versa
- C Program to Convert a Decimal number to Octal Number
- C Program to Convert Number to Words in C
- C Program to Converts a Number to a String.
- C Program to Convert Celsius Temperature into Fahrenheit Temperature
- C Program to Recursively converts all file-names to lower-case
- C Program to accept string from user & convert all lower case letters into upper case letters & vice versa
- C Program To Read The Adjecancy Matrix of Directed Graph And Convert It Into Adjecancy List
Binary Number