Convert decimal to binary using While Loop in C


This program is about convert and print the given decimal number to binary without using arrays using While Loop

Source Code

#include<stdio.h>
int main()
{
  int n,r,m=1,bin=0;
  printf("\nEnter the Number : ");
  scanf("%d",&n);
  while(n!=0)
  {
    r=n%2;
    bin=bin+(r*m);
    m=m*10;
    n=n/2;
  }
  printf("\nBinary Value : %d",bin);
  return 0;
}
            
To download raw file Click Here

Output

Enter the Number :12
Binary Value: 1100

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes