Given a string containing words forming a sentence(belonging to english language). The task is to output the equivalent ASCII sentence of the input sentence.
ASCII form of a sentence is the conversion of each of the character of the input string and aligning them in position of characters present in the string
Input : hello, world! Output : ASCII Sentence: 104101108108111443211911111410810033 Input : GeeksforGeeks Output : ASCII Sentence: 7110110110711510211111471101101107115
To complete the task, we need to convert each character into it’s equivalent ASCII value. We perform the following steps to achieve the equivalent ASCII form of the given sentence-
- Iterate over the length of the complete sentence/string
- Take each character of the sentence at a time, subtract NULL character to it and explicitly typecast the result
- Print the result
Following the above steps, we can achieve the equivalent ASCII form of a given sentence/string.
ASCII Sentence: 7110110110711510211111471101101107115
The time-complexity of converting into equivalent ASCII sentence is , where len is the length of the string.
- Sentence in english language could be encoded/decoded into this form e.g. convert a sentence into it’s equivalent ASCII form and add 5 to each digit and send it from encoder’s side. Later, decoder can subtract 5 from each digit and decode it into it’s original form. This way only the sender and the receiver would be able to decode the sentence.
- ASCII form is also used to transfer data from one computer to another.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.