Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3 4 Sample input from a random text file: abcdefghijklmnopqrstuvwxyz Expected output after conversion: dhlptx|aeimquy}bfjnrvz~cgk 1 #include 2- /* Use the given template to complete
3 4 Sample input from a random text file: abcdefghijklmnopqrstuvwxyz Expected output after conversion: dhlptx|aeimquy}bfjnrvz~cgk 1 #include 2- /* Use the given template to complete the following exercise: read in a text-file containing a string of various characters. Use the sample inputs/outputs and the ASCII table as a reference to map the characters to its expected output equivalent. */ 5. void shift(int output){ 6 //Method to be completed. As much as possible, adhere to bitwise operations only. 7 } 8 int main(void) { 9 int input, output; 10 - while((input = getchar()) != EOF) { 11 if(input == EOF) { 12 break; 13 } 14 output input; 15 shift(output); 16 I/The output characters should be identical to the provided sample output 17 putchar(output); 18 } 19 return 0; 20 } 21 - /*Hints (Use the following tips to complete your code): 22 1. Assume there are no repeated characters from the inputted string and the beginning of a sequence is always a random character 23 from the ASCII table. (i.e. a symbol with a decimal value of 109 gives 'm' from the ASCII table and the following sequence of 24 characters are simply increments of 1 up to a certain extent. (Note that 110 = 'n', 111 = 'o', and so on) 25 Thus continuing the sequence to be = [m, n, op.... ]) 26 27 2. The following can be observed: 28 ABCDEFGHI....XYZ has incrementing integer bit-values per character such that [65, 66, 67, 68, 69, 70, 71, 72, 73 .... 120 121 122] 29 We then apply various bitwise operations to change the characters' integer values when outputted: 30 DHLPTX\AE....CGK has incrementing integer bit-values per character such that [68, 72, 76, 80, 84, 88, 92, 65, 69 .... 67 71 75] 31 From the expected output array of integer bit values, here we notice a common repeating pattern: increment by 4 for a few 32 iterations, and then decrement by 27 (i.e. 84, 88, 92, then suddenly got decremented to 65). 33 */ Another sample input: ABCDEFGHIJKLMNOPQRSTUVWXYZ Expected output: DHLPTX AEIMQUY]BFJNRVZ^NCGK 3 4 Sample input from a random text file: abcdefghijklmnopqrstuvwxyz Expected output after conversion: dhlptx|aeimquy}bfjnrvz~cgk 1 #include 2- /* Use the given template to complete the following exercise: read in a text-file containing a string of various characters. Use the sample inputs/outputs and the ASCII table as a reference to map the characters to its expected output equivalent. */ 5. void shift(int output){ 6 //Method to be completed. As much as possible, adhere to bitwise operations only. 7 } 8 int main(void) { 9 int input, output; 10 - while((input = getchar()) != EOF) { 11 if(input == EOF) { 12 break; 13 } 14 output input; 15 shift(output); 16 I/The output characters should be identical to the provided sample output 17 putchar(output); 18 } 19 return 0; 20 } 21 - /*Hints (Use the following tips to complete your code): 22 1. Assume there are no repeated characters from the inputted string and the beginning of a sequence is always a random character 23 from the ASCII table. (i.e. a symbol with a decimal value of 109 gives 'm' from the ASCII table and the following sequence of 24 characters are simply increments of 1 up to a certain extent. (Note that 110 = 'n', 111 = 'o', and so on) 25 Thus continuing the sequence to be = [m, n, op.... ]) 26 27 2. The following can be observed: 28 ABCDEFGHI....XYZ has incrementing integer bit-values per character such that [65, 66, 67, 68, 69, 70, 71, 72, 73 .... 120 121 122] 29 We then apply various bitwise operations to change the characters' integer values when outputted: 30 DHLPTX\AE....CGK has incrementing integer bit-values per character such that [68, 72, 76, 80, 84, 88, 92, 65, 69 .... 67 71 75] 31 From the expected output array of integer bit values, here we notice a common repeating pattern: increment by 4 for a few 32 iterations, and then decrement by 27 (i.e. 84, 88, 92, then suddenly got decremented to 65). 33 */ Another sample input: ABCDEFGHIJKLMNOPQRSTUVWXYZ Expected output: DHLPTX AEIMQUY]BFJNRVZ^NCGK
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started