In this program, we will take a string as input and check if a given string is binary or not.
Steps to solve the program
- Take a string as input.
- Create a variable count and assign its value equal to 0.
- Use for loop to iterate over each character in the string.
- If the character is 0 or 1 then add 1 to the count variable.
- If the value of the count variable is equal to the length of the string then string is binary.
- Print the output.
Output :