1) “e” function. Similar to the pi() function, create a function that outputs 2.
ID: 3678624 • Letter: 1
Question
1) “e” function. Similar to the pi() function, create a function that outputs 2.71828 when you type ex()
2) Absolute Value Function. Create a function that always outputs a positive number
Absolute(x) = |x|
Absolute(3) = 3
Absolute(-3) = 3
Public Function Absolute(Number as Single) As Single
If (Fill in this Area) Then
(Fill in this Area)
Else
(Fill in this Area)
End If
End Function
9) Triangular Function. Create a function that outputs the result of the Triangular function. This is the same as the Factorial function except, it adds instead of multiplies. Tri(n) = 1 + 2 + 3 + ….n. The function should output the following numbers:
Tri(1) = 1
Tri(2) = 1+2 = 3
Tri(3) = 1+2+3 = 6
Tri(4) = 10
Tri(5) = 15
Here is a code of the function with two lines missing. Write the function by adding in the missing code:
Public Function Tri(Number As Integer) As Integer
Tri = 0
For i = 1 To Number
(Fill in this area)
(Fill in this area)
Next i
End Function
Explanation / Answer
Public Function ex(){
print "2.71828"
}
Public Function Absolute(Number as Single) As Single
If (x>=0) Then
print "x"
Else
x=(-1)x;
End If
End Function
Public Function Tri(Number As Integer) As Integer
Tri = 0
For i = 1 To Number
(Tri=Tri+i)
(print "i")
Next i
End Function
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.