Thursday, October 6, 2022
HomeUncategorizedDecimal to binary conversion (C programming code)

Decimal to binary conversion (C programming code)

#include <stdio.h>
 
int main()
{
  int n, c, k;
 
  printf("Enter an integer in decimal number systemn");
  scanf("%d", &n);
 
  printf("%d in binary number system is:n", n);
 
  for (c = 31; c >= 0; c--)
  {
    k = n >> c;
 
    if (k & 1)
      printf("1");
    else
      printf("0");
  }
 
  printf("n");
 
  return 0;
}
Previous articleKEYBOARD SHORTCUTS KEYS
Next articleFACTORIAL
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular