Home / Expert Answers / Computer Science / write-the-functions-as-described-below-you-need-not-submit-programs-that-use-these-functions-i-w-pa232

(Solved): Write the functions as described below. You need not submit programs that use these functions. (i) W ...



Write the functions as described below. You need not submit programs that use these functions. (i) Write a function that returns the cube of the integer passed to it. For example cube(2) will return 8 and cube(3) will return 27. (ii) (iii) (iv) Write a void function that receives four int parameters: the first two by value and the last two by reference. Name the formal parameters n1, n2, sum and diff. The function should calculate the sum of the two parameters passed by value and then store the result in the first variable passed by reference. It should calculate the difference between the two parameters passed by value and then store the result in the second parameter passed by reference. When calculating the difference, subtract the larger value from the smaller value. Name the function calcSumAndDiff. Write a function void rectangle(int w, int h) to print an open rectangle of asterisks (*). The parameters w and h are the width and the height of the rectangle, expressed in number of asterisks. Write a function, computePrice that receives two parameters: the first one is a character variable indicating the size of the pizza (S, M or L) and the second an integer variable indicating the number of toppings on the pizza. It then computes the cost of the pizza and returns the cost as a floating point number according to the rules: • Small pizza = R50 + R5.50 per topping • Medium pizza = R70 + R6.50 per topping • Large pizza = R90 + R7.50 per topping



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe