[Solved] CSCI1300 Homework 8-Binary numbers and recursive functions

$25

File Name: CSCI1300_Homework_8_Binary_numbers_and_recursive_functions.zip
File Size: 546.36 KB

SKU: [Solved] CSCI1300 Homework 8-Binary numbers and recursive functions Category: Tag:
5/5 - (1 vote)

Objectives

  • Learn binary numbers and how to use recursive functions Develop some methods that will be useful in your future!

You can find hw8 note: binary and recursio n on Moodle.

Questions

Question 1: decimalToBinaryIterative

Write a function decimalToBinaryIterative that converts a decimal value to binary using a loop. This function takes a single parameter, a non-negative integer, and returns a string corresponding to the binary representation of the given value.

Function specifications:

  • The function name: decimalToBinaryIterative
  • The function parameter: An integer to be converted to binary
  • Your function should return the binary representation of the given value as a string
  • Your function should not print anything
  • Your function should use a loop
Sample main (Be sure to test all methods!) Expected outputs
decimalToBinaryIterative(5) decimalToBinaryIterative(8) 1011000

The file should be named as iterative.cpp . Dont forget to head over to the code runner on Moodle and paste your solution in the answer box! In the main, make sure to have test cases.

Question 2: decimalToBinaryRecursive

Write a function decimalToBinaryRecursive that converts a decimal value to binary using recursion. This function takes a single parameter, a non-negative integer, and returns a string corresponding to the binary representation of the given value.

Function specifications:

  • The function name: decimalToBinaryRecursive
  • The function parameter: An integer to be converted to binary
  • Your function should return the binary representation of the given value as a string
  • Your function should not print anything
  • Your function should use recursion. Loops are not allowed.
Sample main (Be sure to test all methods!) Expected outputs
decimalToBinaryRecursive(5) decimalToBinaryRecursive(8) 1011000

The file should be named as recursive.cpp . Dont forget to head over to the code runner on Moodle and paste your solution in the answer box! In the main, make sure to have test cases.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCI1300 Homework 8-Binary numbers and recursive functions[Solved] CSCI1300 Homework 8-Binary numbers and recursive functions
$25