Hello,
Algorithm: Generating Bitstream (for e.g., 0`s and 1`s)
While compiling this program its showing compiling error. Looking over my program , point out whats wrong in the following codes.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int bin_verify(char[]);
int main()
{
char bin1[33],bin2[33],result[33];
int len1, lens2,check;
printf("Enter binary number 1:");
scanf ("%s", bin1);
printf("Enter binary number 2:");
scanf ("%s", bin2);
check=bin_verif y(bin1);
if(check)
{
printf("Invalid binary number%s.\n", bin1);
exit(0);
}
check =bin_verify(bin 2);
if(check)
{
printf("Invalid binary number%s.\n", bin2);
exit(0);
}
printf("output binary %s.\n", bin1);
printf("output binary %s.\n", bin2);
return 0;
}
int bin_verify(char str[])
{
int i;
for (i=0;i<strlen(s tr);i++)
{
if((str[i]-'0'!=1)&&(str[i]-'0!=0'))
{
return 1;
}
}
return 0;
}
Algorithm: Generating Bitstream (for e.g., 0`s and 1`s)
While compiling this program its showing compiling error. Looking over my program , point out whats wrong in the following codes.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int bin_verify(char[]);
int main()
{
char bin1[33],bin2[33],result[33];
int len1, lens2,check;
printf("Enter binary number 1:");
scanf ("%s", bin1);
printf("Enter binary number 2:");
scanf ("%s", bin2);
check=bin_verif y(bin1);
if(check)
{
printf("Invalid binary number%s.\n", bin1);
exit(0);
}
check =bin_verify(bin 2);
if(check)
{
printf("Invalid binary number%s.\n", bin2);
exit(0);
}
printf("output binary %s.\n", bin1);
printf("output binary %s.\n", bin2);
return 0;
}
int bin_verify(char str[])
{
int i;
for (i=0;i<strlen(s tr);i++)
{
if((str[i]-'0'!=1)&&(str[i]-'0!=0'))
{
return 1;
}
}
return 0;
}
Comment