Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 (50 points) Write a function that is able to calculate the resistance of a metal given the resistivity of a particular metal (expressed

Part 1 (50 points)

Write a function that is able to calculate the resistance of a metal given the resistivity of a particular metal (expressed as a double), the length of the wire in meters (expressed as an int), and the diameter of the wire in millimeters (expressed also as an int).

  1. Be sure to write at least one multi-line comment above the function describing what it does, how to use it, etc..
  2. In addition, within the function, include comments explaining what the pieces of your code are doing.

The formula for calculating the resistance of a metal is as follows:

Resistance = resistivity * length of wire / area of wire

Here is the prototype for the function that you must follow. In vocareum, the prototype is already written into hw2.h and MUST be included in your file. Your c file should also be named hw2.c.

Example: #include "hw2.h" This should be at the top of your hw2.c file

double calc_resistance(double resistivity, int length_m, int diameter_mm);

Tips for part 1: The math library includes constants (variables whose values cannot be modified) and functions useful for math. If you include the library, you can use them as-if you had created them in your file.

Here are a few that might be helpful:

M_PI = value of P

M_PI_4 = value of P / 4

result = pow(number, power you want to raise it to)

Keep in mind that you will be given the DIAMETER of the wire in mm. The formula uses the area of a wire. After converting from some diameter (in mm) to area you will end up with some area mm2. You will need to account for that when you use the number in your formula.

Part 2 (50 points each correctly calculated term up to 46 will result in 1/46th % credit of the 50 pts)

Write a function that can calculate the nth term in the Fibonacci sequence given some whole number n. You should use Binets formula in your function to solve this. You DO NOT need to worry about negative numbers for n.

Your function ONLY needs to be correct up to the 46th fib term.

Below is the prototype for the function you will be making. It will be included in hw2.h.

int calc_fibn(int n);

Here are links explaining both the Fibonacci series and Binets formula to calculate the nth term of the Fibonacci series.

https://www.mathsisfun.comumbers/fibonacci-sequence.html

http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html

You can check your work here:

http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibtable.html

TIP for implementing Binets formula in C:

The square root of a number can be expressed as that number raised to the .5 power (think about how to represent phi in Binets formula). image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

5. Identify the logical fallacies, deceptive forms of reasoning

Answered: 1 week ago

Question

6. Choose an appropriate organizational strategy for your speech

Answered: 1 week ago