Answer : We need to use recursion for this, and here is my version of the C code for the same
#include <stdio.h>
void printBinary(int k)
{
if(k != 0)
{
printBinary(k/2);
}
printf("%d", k%2);
}
void main(void)
{
int k = 4561;
printBinary(k);
}
No comments:
Post a Comment