CONVERSION OF DECIMAL TO BINARY USING C PROGRAM

CONVERSION OF DECIMAL TO BINARY USING C PROGRAM


Solution:


#include<stdio.h>
int main(){
  long int m,no=0,a=1;
  int n,rem;
  printf("Enter any decimal number->");
  scanf("%d",&n);
  m=n;
  while(n!=0){
      rem=n%2;
      no=no+rem*a;
      n=n/2;
     a=a*10;
  }
  printf("The value %ld in binary is->",m);
  printf("%ld",no);
  return 0;
}

More C Program:


  1. CONVERSION OF DECIMAL TO BINARY USING C PROGRAM
  2. c program for decimal to binary conversion without using array
  3. simple c program for decimal to binary conversion
  4. c program to convert decimal to binary without using array
  5. c program to convert decimal to binary using function
  6. c program to convert decimal to binary using stack
  7. c program to convert decimal to binary using bitwise operators
  8. c program to convert decimal to binary using while loop
  9. c program to convert decimal to binary using recursion


Learn More :