Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »

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);
. 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 a
ay 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 XXXXXXXXXX = 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 a
ays as parameters in functions, and use function calls within other functions. Write a program that uses function calls to sort an a
ay of 5 numbers from least to greatest, and prints the newly sorted a
ay after it has been sorted directly from the sort function. To pass an a
ay into a function, we must first declare that we are passing an a
ay in the prototype, and when we call it, we just need to specify the a
ay name without the square
ackets. You’re going to have to do some research here! (Hint: A nested loop will really help you with this. Follow the Bu
lesort algorithm on this website if you can’t think of anything, but make sure you cite your source in your comments! https:
illiant.org/wiki
u
le-sort/)
Answered Same Day Dec 23, 2021

Solution

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