String Challenge Have the function StringChallenge (str) take the str parameter being passed, which will be a positive integer, take its binary representation (padded to the nearest N * 8 bits), reverse that string of bits, and then finally return the new reversed string in decimal form. For example: if str is "47" then the binary version of this integer is 101111 but we pad it to be 00101111. Your program should reverse this binary string which then becomes: 11110100 and then finally return the decimal version of this string, which is 244. Examples Input: "213" Output: 171 Input: "4567" Output: 60296

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

 

Js question in row ra. 

 

String Challenge
Have the function StringChallenge (str) take the str parameter being passed,
which will be a positive integer, take its binary representation (padded to the nearest N * 8 bits),
reverse that string of bits, and then finally return the new reversed string in decimal form.
For example: if str is "47" then the binary version of this integer is 101111 but we pad it to be 00101111.
Your program should reverse this binary string which then becomes: 11110100 and then finally return the decimal
version of this string, which is 244.
Examples
Input: "213"
Output: 171
Input: "4567"
Output: 60296
Transcribed Image Text:String Challenge Have the function StringChallenge (str) take the str parameter being passed, which will be a positive integer, take its binary representation (padded to the nearest N * 8 bits), reverse that string of bits, and then finally return the new reversed string in decimal form. For example: if str is "47" then the binary version of this integer is 101111 but we pad it to be 00101111. Your program should reverse this binary string which then becomes: 11110100 and then finally return the decimal version of this string, which is 244. Examples Input: "213" Output: 171 Input: "4567" Output: 60296
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 7 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning