P163. Using recursion function design a program for binary printing.
#include<stdio.h>
void
binary(int);
void
main()
{
int num;
printf("Enter a number : ");
scanf("%d",&num);
binary(num);
printf("\n");
}
void
binary(int nu)
{
static int pos=31;
if(pos>=0)
{
printf("%d",nu>>pos&1);
pos--;
binary(nu);
}
else
return;
}
Comments
Post a Comment