Program to print all binary string of n length .

program:-

#include<stdio.h>
void main()
{
void bin(int ,char[]); // function declaration
int l;
char s[100];
printf(“Enter the length of string “);
scanf(“%d”,&l);
s[l]=0;
bin(l,s); // function calling
}

// function definition
void bin(int n,char s[])
{
if(n<1)
{
printf(“%sn”,s);
}
else
{
s[n1]=‘0’;
bin(n1,s);
s[n1]=‘1’;
bin(n1,s);
}
}


Leave a Reply

Your email address will not be published.