Discussion Notes 4

# Discussion Notes 4 - EME 5 Discussion 4 Function Random...

This preview shows pages 1–7. Sign up to view the full content.

EME 5 Discussion 4 Function Random Number Generation Define Macros Header, Function, and Application Files

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Function (a) Function prototype : returntype functionname(argumenttype [argumentname]); (b) Function definition : returntype functionname(argumenttype argumentname) { statements; return returnvalue; }
Function (contd.) (c) Common errors : 1) returnvalue does not have the type that matches returntype 2) functionname in definition does not match functionname in prototype 3) argumenttype/argumentname in definition does not match argumenttype/argumentname in prototype

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Function (contd.) In Ch, write a function that returns the value of f(x). Print the values of f(x) for -10<=x<=10 with x_step = 0.5. Plot f(x) with 50 points for x. f(x)=sin(x).
Function (contd.) Need: 1) for-loop 2) Ch plotting function fplotxy() int fplotxy(double (*func)(double), double x0, double xf, int num, char *title, char *xlabel, char *ylabel);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Function (contd.) #include <math.h> #include <stdio.h> #include <chplot.h> double f(double); int main() { double x, xstep = 0.5, y;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern