Question
please help this function using Blitz3D
Using Blitz3D 1. This function returns the sum of five numbers 2. This function returns the quotient of dividing a smaller nu
0 0
Add a comment Improve this question Transcribed image text
Answer #1

;note:- I have used real numbers as input and return type
;for all the functions, this is because using real numbers
;allows to perform the specified opertions for both integers
;and real numbers.

Function sumFive#(a#,b#,c#,d#,e#) ; start of sumFive function


; this function calculates the sum of five different real numbers
; the function takes input five real numbers and returns their sum as a real number

sum#=a#+b#+c#+d#+e#       ;performing the addition

Return sum#               ;returning the result

End Function           ; end of sumFive function

Function divSmlByLrg#(s#,l#) ; start of divSmlByLrg function


; this function divides a small number by a large number
; the function takes input two real numbers and returns the result
; of dividing the small number by the large number always
; by default this function considers that s# contains the smaller
; number and l# contains the larger number but if at the time of
; function call if the values are swapped , that is s# contains the larger
; number and l# the smaller number, then the function re-swaps them
; thus always returning the value obtained by dividing the smaller by the
; larger number

If s#>l# ; checking if s# contains the larger value and not l#
; swapping the numbers if the condition is true
t#=s# ; storing the value of s# in a temporary variable t#

s#=l# ; copying the value of l# to s#

l#=t# ; copying the value of s# stored in the temporary
; variable t# to l#

EndIf

quotient#=s#/l# ; calculating the quotient

Return quotient# ; returning the result

End Function ; end of divSmlByLrg function


Function difference#(a#,b#) ; start of difference function


; this function finds the difference of two numbers
; the function takes input two real numbers and returns their difference
; as a real number


diff#=a#-b# ; calculating the difference

Return diff# ; returning the result

End Function ; end of difference function


Function product#(a#,b#) ; start of product function


; this function finds the product of two numbers
; the function takes input two real numbers and returns their product
; as a real number


prod#=a#*b# ; calculating the product

Return prod# ; returning the result

End Function ; end of product function

sf#=sumFive(6,3,4,5.2,1.2) ; calling the sumFive function with a mix of integers and real numbers
; and storing the retuned value in the real number variable sf#

dv#=divSmlByLrg(5,3.5) ; calling the divSmlByLrg function with a mix of integers and real numbers
; and storing the retuned value in the real number variable dv#

df#=difference(5,3.2) ; calling the difference function with a mix of integers and real numbers
; and storing the retuned value in the real number variable df#

pr#=product(3.1,7) ; calling the product function with a mix of integers and real numbers
; and storing the retuned value in the real number variable pr#


Print "sumFive function has returned the value:"+sf# ; displaying the result of sumFive function

Print ; printing a new blank line to increase space between the outputs

Print "divSmlByLrg function has returned the value:"+dv# ; displaying the result of divSmlByLrg function

Print ; printing a new blank line to increase space between the outputs

Print "difference function has returned the value:"+df# ; displaying the result of difference function

Print ; printing a new blank line to increase space between the outputs

Print "product function has returned the value:"+pr# ; displaying the result of product function


; Hope I have made the answers clear , do comment if you have any doubt I would love to clarify them
; all the best

Add a comment
Know the answer?
Add Answer to:
Using Blitz3D 1. This function returns the sum of five numbers 2. This function returns the quoti...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please create a Java Program, Using Netbeans JDK, that Asks the operator for 2 numbers, and...

    Please create a Java Program, Using Netbeans JDK, that Asks the operator for 2 numbers, and the user's First and Last Name, and calculates the sum, difference, quotient, and product of the 2 numbers. The program should display to screen: "Hello ";{First Name Last Name} "The Sum is ": {Sum} "The Difference is ": {Difference} "The Product is: ": {Product} "The Quotient is ": {Quotient} Each student should post a Java program should have: (a) Pseudocode and (b) adjacent Java...

  • 1. Write a recursive function that computes the sum of all numbers from 1 to n,...

    1. Write a recursive function that computes the sum of all numbers from 1 to n, where n is given as parameter. Here is the method header: public static int sum (int n){...} 2. Write a recursive function that finds and returns the minimum value in an array, where the array and its size are given as parameters. Here is the method header: public static int minValue (int [] data, int size){...} 3. Write a recursive function that reverses the...

  • write the C++ program to do the following 1. read in 2 numbers as ints 2....

    write the C++ program to do the following 1. read in 2 numbers as ints 2. calculate the sum, difference, product, and quotient 3. print out the four calculated numbers in the following       format           the two input numbers are ??? and ???              sum is             ????              difference is     ????              product is        ????              quotient is       ?????.?????? where ??? represents the ints and ????.???? represents the decimals. You can have any number of decimal places Example: Assume...

  • How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button...

    How to find sum of the first and last 3 numbers? #Javascript Function P2<yourname>. When button "problem 2" is clicked, a JavaScript function equivalent to the following flowchart should execute. In other words, your task here is to translate the following flowchart to JavaScript code in P2<yourname>: start sum1 0 sum2 0 P i0 i< 3 iei+1 num sum1 sum1 + num F i <3 ii+1 sum1 sum2 "no" num "yes" sum2 sum2 + num end Hint: for input, use...

  • def sum_gt_avg(num_list): Implement a function that returns the sum of the numbers in num_list that have...

    def sum_gt_avg(num_list): Implement a function that returns the sum of the numbers in num_list that have a value greater than the average value in the list. • Parameters: num_list is a list of numbers (mixed integers and floats) • Examples: sum_gt_avg([1,2,3,4,5]) → 9 # 4+5 sum_gt_avg([1,2,3,-4,5]) → 10 # 2+3+5 sum_gt_avg([-1,-2,-3,-4,-5]) → -3 # -1-2

  • IN PYTHON 3.7.4 1. Write a function that gets two numbers from the user and returns...

    IN PYTHON 3.7.4 1. Write a function that gets two numbers from the user and returns an absolute value of the smaller number. For example, if the user enters -7 and 4, the function returns 7. 2. Write a function that gets two numbers from the user. If the two numbers are consecutive, return “Consecutive”. Otherwise, return “Not Consecutive”.

  • ANSWER USING JAVA CODE (1)The sum of the squares of the first ten natural numbers is,...

    ANSWER USING JAVA CODE (1)The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. Find the difference between the...

  • This is for programming using Python with the JES software. Please write the code with the...

    This is for programming using Python with the JES software. Please write the code with the proper indentation. Thanks! Problem 1: Write a function that takes 2 arguments (integer or float) and computes the sum, difference, product, and quotient of the arguments. Once you calculate the values you should print out statements telling the user what arguments we used to compute the values and what the result of each calculation (your function should produce 5 lines of output in the...

  • 1. use python List to Dictionary Write a function that has three parameters: a list of...

    1. use python List to Dictionary Write a function that has three parameters: a list of unsorted numbers with no duplicates, a start number, and an end number. This function should return a dictionary with all integers between the start and end number (inclusive) as the keys and their respective indices in the list as the value. If the integer is not in the list, the corresponding value would be None. Example unsorted list: [2,1,10,0,4,3] two numbers: 3, 10 returned...

  • 2. This function compares two numbers and returns them in increasing order. 1. Fill in the...

    2. This function compares two numbers and returns them in increasing order. 1. Fill in the blanks, so the print statement displays the result of the function call in order. 1 # This function compares two numbers and returns them 2 # in increasing order. 3 - def order_numbers(number1, number2): 4. if number2 > number1: return numberi, number2 6 else: return number2, number1 9 Run # 1) Fill in the blanks so the print statement displays the result # of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT