C Program to Convert Decimal to Binary using Bitwise Operator

C Program to Convert Decimal into Binary using Bitwise Operator

This page has a C Program to Convert Decimal to Binary using Bitwise Operator. It is clear that, this C program will Convert Decimal to Binary using Bitwise Operator. For Example: If the Decimal number 27 is given as input, the program will print the binary equivalent as 11011 The below given C program is used to Convert Decimal to Binary using Bitwise OperatorKindly check out the program to Convert Decimal into Binary using Bitwise OperatorThe Questions to Convert Decimal number into Binary Number problem can be asked as . .

1). C Program to Convert Decimal number to Binary Number using Bitwise Operator.   

2). C Program to Convert the given Decimal number into Binary Number using Bitwise Operator 

3). C Program to find the Binary equivalent of given Decimal number using Bitwise Operator.

4). C Program to Print Binary Equivalent of a Decimal Integer using Bitwise Operator.

5). Program to convert decimal to binary in c using Bitwise Operator

Decimal to Binary using Bitwise Operator Program - First Method


    #include<stdio.h>
    #include<conio.h>
    void decimal_to_binary(unsigned int);
    int main(){
                  unsigned int number;
                  clrscr();
                  printf("Enter a Decimal Number : ");
                  scanf("%u",&number);
                  decimal_to_binary(number);
                  getch();
    return(0);
    }
    void decimal_to_binary(unsigned int n){
                 unsigned int range=32768;
                 printf("\n The Binary Eqivalent is ");
                 xy:
                 if(range > 0)
                 {
                 if((n & range) == 0 ){
                 range = range >> 1 ;
                 goto xy; }
                 else
                 while(range>0){
                 if((n & range) == 0 )
                 printf("0");
                 else
                 printf("1");
                 range = range >> 1 ;
                 }
                 }
    }


Decimal to Binary using Bitwise Operator Program - Second Method for very large Number


    #include<stdio.h>
    #include<conio.h>
    void decimal_to_binary(unsigned long int);
    int main(){
                 unsigned long int number;
                 clrscr();
                 printf("Enter a big decimal number : ");
                 scanf("%lu",&number);
                 decimal_to_binary(number);
                 getch();
    return(0);
    }
    void decimal_to_binary(unsigned long int n){
                 unsigned long int range=2147483648;
                 printf("\n The Binary Eqivalent is ");
                 xy:
                 if(range > 0)
                 {
                 if((n & range) == 0 ){
                 range = range >> 1 ;
                 goto xy; }
                 else
                 while(range>0){
                 if((n & range) == 0 )
                 printf("0");
                 else
                 printf("1");
                 range = range >> 1 ;
                 }
                 }
    }


Sample Output:

Enter an Integer decimal number : 13

The given decimal number is : 13

The Binary number is : 1101

Related Other Popular C Programs

*  Write a c program to check whether a given number is prime number or not?

 

*  Write a C program to find the prime numbers between 1 and 100

 

*  Write a C program to display the prime numbers between a range ?

 

*  Write a C program to find the prime numbers between a range using while loop?

 

*  Write a C program to find the sum of prime numbers between a range 

About Er. T.Tharesh Kumar

I am a Professor and Head of Department of Computer Science in an Arts and Science College. I have designed this website to provide solved example programs of different categories for all the school and college going students to learn C language deeply, and to practice Interview based Multiple Choice (Objective Type) questions and answers.

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share