Simple function/variable problem

  • Thread starter wallace13
  • Start date
In summary, a simple function is a reusable block of code that takes in input, processes it, and returns an output. Variables can be declared using the keyword "var" and parameters can be passed by including them in the parentheses after the function name. Global variables can be accessed by any function, while local variables can only be accessed within the specific function they are declared in. A simple function can also return multiple values using an array or object.
  • #1
wallace13
31
0
The base of an isosceles triange has length b and the two sides of equal length each measure 30 cm. Find the area A of the triangle as a function of b.


a squared + b squared = c squared
Area= .5bh

.5b squared + h squared = 30 squared
h= (-.5b squared + 900) ^ 1/2

Area= .5 x b x [(-.5b squared + 900)^ 1/2]

Is this correct?
 
Physics news on Phys.org
  • #2
Well it is sort of ambiguous what you mean by the -.5b squared, but if you meant

[tex] A = \frac{b}{2} \cdot \sqrt{ 900 - \frac{b^2}{4} }[/tex]

as you probably did, then yes, its correct ! =]
 

Related to Simple function/variable problem

1. What is a simple function?

A simple function is a block of code that performs a specific task. It takes in input, processes it, and returns an output. It is designed to be reusable and can be called multiple times throughout a program.

2. How do I declare a variable in a simple function?

To declare a variable in a simple function, you can use the keyword "var" followed by the variable name, an equals sign, and the value you want to assign to the variable. For example: var num = 5;

3. What is the difference between a global variable and a local variable in a simple function?

A global variable is declared outside of a function and can be accessed by any function within the program. A local variable is declared inside a function and can only be accessed within that specific function. Local variables have a limited scope and are destroyed once the function finishes executing.

4. How do I pass parameters to a simple function?

To pass parameters to a simple function, you can include them within the parentheses after the function name. For example: function addNumbers(x, y) { //code to add x and y }

5. Can a simple function return more than one value?

Yes, a simple function can return more than one value by using an array or an object. For example: function returnValues() { return [1, 2, 3]; } or function returnValues() { return {num1: 1, num2: 2, num3: 3}; }

Similar threads

  • Calculus and Beyond Homework Help
Replies
29
Views
1K
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
  • Calculus and Beyond Homework Help
Replies
1
Views
686
  • Calculus and Beyond Homework Help
Replies
6
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
991
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
187
  • General Math
Replies
4
Views
890
  • Calculus and Beyond Homework Help
Replies
6
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
1K
Back
Top