Are you talking about a char calculation or an int calculation? Everything has a binary equivalent. But not every binary sequence has a char or int equivalent.
It's not obvious what the variable names represent, since there are no variable definitions here.
But just looking at the beginning of the code, there's this:
1 2 3 4 5
do
{
cout<<"Enter a Binary Digits: ";
cin>>binary;
} while (array[i]<0 && array[i]>1);
I've no idea what array and i represent. But since none of them are changed inside the loop, it doesn't make sense to use them as the condition.
More importantly, regardless of value, array[i] cannot simultaneously be negative and a positive number bigger than 1. Hence the while condition is always false.
That's as far as I got in looking at the code, it makes no particular sense up to that point, I can't say whether the rest is ok or not (though I could guess).
and your syntax shinigami is totally conflicting with other functions.
Yes it is. But you asked
I'm trying to know how can i validate an input if it's valid for binary digit or not.
Not to make a code you can use in your program. And my code validates it.
But my code use std::string and your use int (I guess).
And you don't use any functions. But it would be ease if you make your code into several small functions.
if you use int as binary digit, you can get only number as big as int. In my system it would be number 1111111111. Can get any larger number. But if you take a string, you can get binary off any size. But you won't be able to use it in int calculations like you do in your code.
if you take a string, you can get binary off any size. But you won't be able to use it in int calculations
It's true you couldn't use the string directly in calculations.
But its simple enough to convert the binary string to a real integer, either by using a built-in function such as strtol(), or by writing a short piece of code to do the same job.
Although you could put forward arguments in favour of either approach, personally I'd take the string as my first choice.