Questions: 1. The following function computes the area of a triangle, but there are three problems with it. State the problem and tell me how to fix it 2. Which of the following would be valid...

1 answer below »
Its all on the word


Questions: 1. The following function computes the area of a triangle, but there are three problems with it. State the problem and tell me how to fix it 2. Which of the following would be valid prototypes for a function that returns nothing and has one float parameter? For those that aren’t, explain why they don’t work a. void f(float x); b. void f(float); c. void f(x); d. f(float x); 3. The following function is improper as it has too many return statements. Rewrite it so that it only has one, and place a snapshot of your code on the doc as your solution. 4. What’s the output of the following program? 5. What is the purpose of a recursive function? Give an example of when we might need to use one, besides what we used in the slides. If you Google an answer, make sure you cite your sources! Programs: 1. Create a program that has three functions: one that calculates the area of a rectangle, one that calculates the perimeter, and one that prints the results. 2. Create a program that uses functions to calculate power of a number raised to another. E.g.- ab. 3. Create a program to get the largest element of an array using at least two function calls. 4. A “perfect number” is a number that has all its factors (except itself) add up to the number. So, for example, 28 is a perfect number because it’s factors are 1, 2, 4, 7, 14, and 28, and 1+2+4+7+14 = 28. Write a program with at least two function calls that tells us if a number is perfect or not. 5. Edit the program in question 2 using recursion. 6. We can pass arrays as parameters in functions, and use function calls within other functions. Write a program that uses function calls to sort an array of 5 numbers from least to greatest, and prints the newly sorted array after it has been sorted directly from the sort function. To pass an array into a function, we must first declare that we are passing an array in the prototype, and when we call it, we just need to specify the array name without the square brackets. You’re going to have to do some research here! (Hint: A nested loop will really help you with this. Follow the Bubblesort algorithm on this website if you can’t think of anything, but make sure you cite your source in your comments! https://brilliant.org/wiki/bubble-sort/)
Answered Same DayDec 23, 2021

Answer To: Questions: 1. The following function computes the area of a triangle, but there are three problems...

Shubham answered on Dec 24 2021
113 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here