Given a string of character the task is to convert each character of a string into the equivalent binary number.
Input : GFG Output : 1000111 1000110 1000111 Input : geeks Output : 1100111 1100101 1100101 1101011 1110011
The idea is to first calculate the length of the string as n and then run a loop n times. In each iteration store ASCII value of character in variable val and then convert it into binary number and store result in array finally print the array in reverse order.
1100111 1100101 1100101 1101011 1110011
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Longest sub-sequence of a binary string divisible by 3
- Convert an unbalanced bracket sequence to a balanced sequence
- Minimum operations required to convert a binary string to all 0s or all 1s
- Minimum given operations required to convert a given binary string to all 1's
- Minimum steps to convert one binary string to other only using negation
- Minimum swaps required to convert one binary string to another
- Periodic Binary String With Minimum Period and a Given Binary String as Subsequence.
- Convert a sentence into its equivalent mobile numeric keypad sequence
- Minimum number of given operations required to convert a string to another string
- Convert the string into palindrome string by changing only one character.
- Convert string X to an anagram of string Y with minimum replacements
- Convert Hexadecimal value String to ASCII value String
- String with additive sequence
- Find Index of 0 to be replaced with 1 to get longest continuous sequence of 1s in a binary array | Set-2
- Lexicographically largest sub-sequence of the given string
- Convert Binary fraction to Decimal
- Replace every consonant sequence with its length in the given string
- Check if there exists any sub-sequence in a string which is not palindrome
- Convert Ternary Expression to a Binary Tree
- Convert decimal fraction to binary number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.