Computer Science, asked by Hamma6009, 1 year ago

Write a program to convert the given decimal number into binary number in c program

Answers

Answered by anabiyamalik307
3

Answer:

#include <stdio.h>

 

int main()

{

 int n, c, k;

 

 printf("Enter an integer in decimal number system\n");

 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;

}

Explanation:

Answered by akashsshinde
3

Answer:

For a given number in binary, having combinations of 1s and 0s only, write a program that outputs the decimal equivalent of the binary number represented by the binary number. The input binary number will always be of length 4. You can write your program accordingly

For example,

for the input provided as follows:

1111

The function should return

15

Similar questions