Professional Documents
Culture Documents
#include <stdio.h>
#include <string.h>//we will use string to store the binary input from the user as
we do not have a data type to accept the binary input
#include <stdlib.h>
int bin_verify(char []);//to check if it is a valid binary number
void count();//to count 0 and 1
int check,zeros = 0,ones = 0;
char bin1[33];
int main()
{
printf("Enter binary number : ");
scanf("%s", bin1);
check = bin_verify(bin1);
if (check)
{
printf("Invalid binary number %s.\n", bin1);
exit(0);
}
else
{
count();
}
}
int bin_verify(char str[])
{
int i;