Menu

Hello I Am Stuck In My Code And Confused In The Question. Help Please. It’s Written In Coral Coding Language. Here’s The Question: Define A Function Named IntegerToBinary That Takes A Positive Integer As A Parameter And Outputs A String Of 1’S And 0’S Representing The Integer In Binary In Reverse Order. Then, Write A Main Program That Reads A Positive

Hello I am stuck in my code and confused in the question. Help please. It’s written in Coral coding language.

Here’s the question:

Define a function named IntegerToBinary that takes a positive integer as a parameter and outputs a string of 1’s and 0’s representing the integer in binary in reverse order. Then, write a main program that reads a positive integer as input and calls function IntegerToBinary() with the input as an argument. Function IntegerToBinary() will output the binary representation of the input argument in reverse order.

For an integer x, the algorithm is:

As long as x is greater than 0
Output x % 2 (remainder is either 0 or 1)
x = x / 2
Note: The above algorithm outputs the 0’s and 1’s in reverse order.

Ex: If the input is:

6
the output is:

011
Your program should define and call a function:
Function IntegerToBinary(integer num) returns nothing

Here’s my code:

Function IntegerToBinary(integer num) returns nothing
While num > 0
Output num % 2
num = num / 2
End While
End Function

Function Main() returns nothing
integer num = Input()
IntegerToBinary(num)
End Function

Expert Answer

Step 1

Here are some changes that I have made,

OR