Skip to main content

Posts

Showing posts from December, 2013

C Program to print the decimal number in Binary using bit wise operators.

Algorithm:- Step 1. Read the decimal number in a variable              Read num Step 2. Loop from 31 bit position to 0 th bit              Loop i = 31 to 0 Step 3. Left shift 1 by the [i]th Index             mask = 1 << i Step 4. perform  ( & ) operation on the num and mask and print the results         if (num & mask == 0)                       print 0           else                       print 1 C Program:- #include<stdio.h>  /* program for binar...