#include <stdio.h> int binary(int); int main() { int num,bin; printf("enter a decimal number:"); scanf("%d",&num); bin=binary(num); printf("the binary rquivalent of %d %d",num,bin); } int binary(int num) { if(num==0) { return 0; } else { return (num%2)+10*binary(num/2); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter