Purchase Solution

Sub Algorithms Base Values

Not what you're looking for?

Ask Custom Question

? Write a sub-algorithm (subroutine) that given a number N in base 10 and a base value Base between 2 and 10 (inclusive), returns the representation of the decimal value N in the desired Base. For example, given N = 25, and Base = 2, it should return 11001.
Algorithm: Base_10_to_Any_Base
1.0 Given:
1.1 an integer N, a decimal value
1.2 an integer Base, a base between 2 and 10
2.0 Declare variable Result
...

? Write a sub-algorithm (subroutine) that given a string Number representing a number in some base and a base value Base between 2 and 10 (inclusive), returns the representation of Number as a decimal value. For example, given Number = 11001, and Base = 2, it should return 25.
Algorithm: Any_Base_to_Base_10
1.0 Given:
1.1 a string Number, a string of digits,
1.2 an integer Base, a base between 2 and 10
2.0 Declare variable Result
...

? Write an algorithm, that uses the above two sub-algorithms, given a number in some base from and a different base named to, converts the number from the original base to the desired base.
Algorithm: Any_Base_to_Any_Base
1.0 Given:
1.1 a string Number, a string of digits,
1.2 an integer From, a base between 2 and 10
1.2 an integer To, a base between 2 and 10
2.0 Declare variable Result
...

Purchase this Solution

Solution Summary

Sub algorithm base values are examined. The expert declares the results.

Solution Preview

1. Algorithm: Base_10_to_Any_Base
String Base_10_to_Any_Base(int N, int Base)
BEGIN
1. Define a string str = ""
2. While (N>0) Then
2.1. str = str + (N%Base)
2.2 N = N/Base
End ...

Purchase this Solution


Free BrainMass Quizzes
Know Your Linear Equations

Each question is a choice-summary multiple choice question that will present you with a linear equation and then make 4 statements about that equation. You must determine which of the 4 statements are true (if any) in regards to the equation.

Graphs and Functions

This quiz helps you easily identify a function and test your understanding of ranges, domains , function inverses and transformations.

Geometry - Real Life Application Problems

Understanding of how geometry applies to in real-world contexts

Exponential Expressions

In this quiz, you will have a chance to practice basic terminology of exponential expressions and how to evaluate them.

Solving quadratic inequalities

This quiz test you on how well you are familiar with solving quadratic inequalities.