Q:

C Program to find Binary number of a Decimal number

0

C Program to find Binary number of a Decimal number

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>


void getBinary(int);

int main()
{
	int num=0;
	printf("Enter an integer number :");
	scanf("%d",&num);
	printf("\nBinary value of %d is =",num);
	getBinary(num);
	return 0;
}


void getBinary(int n)
{
	int loop;
	
	for(loop=15; loop>=0; loop--)
	{
		if( (1 << loop) & n)
			printf("1");
		else
			printf("0");
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now