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
- Longest sub-sequence of a binary string divisible by 3
- Convert an unbalanced bracket sequence to a balanced sequence
- Minimum given operations required to convert a given binary string to all 1's
- Minimum swaps required to convert one binary string to another
- Minimum operations required to convert a binary string to all 0s or all 1s
- Minimum steps to convert one binary string to other only using negation
- Convert a sentence into its equivalent mobile numeric keypad sequence
- Minimum number of given operations required to convert a string to another string
- Convert string X to an anagram of string Y with minimum replacements
- Convert the string into palindrome string by changing only one character.
- 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
- Convert Binary fraction to Decimal
- Lexicographically largest sub-sequence of the given string
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.