I have written a function that takes in a positive decimal and returns its Binary equivalent; however, the output always adds an additional zero to the binary.
what could I do to get rid of it?
If the number is 7, it outputs 0111 instead of 111.
Here is my code:
Thank you in advance...Code:#include <stdio.h> void Dec(int n) { if(n > 0) Dec(n/2); printf("%i", n%2); } int main() { int x; printf("Enter a Positive Decimal Number Please\n"); scanf("%d",&x); Dec(x); printf("\n"); }