• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 07, 2022 |6.1K Views

Convert String into Binary Sequence

  Share   Like
Description
Discussion

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.

Given a string of character the task is to convert each character of a string into the equivalent binary number.
Examples : 
 


Input : GFG
Output : 1000111 1000110 1000111  

Input :  geeks
Output : 1100111 1100101 1100101 1101011 1110011  


Convert String into Binary Sequence : https://www.geeksforgeeks.org/convert-string-binary-sequence/