Discussion Notes 4

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

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

View Full Document Right Arrow Icon
EME 5 Discussion 4 Function Random Number Generation Define Macros Header, Function, and Application Files
Image of page 1

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

View Full Document Right Arrow Icon
Function (a) Function prototype : returntype functionname(argumenttype [argumentname]); (b) Function definition : returntype functionname(argumenttype argumentname) { statements; return returnvalue; }
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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).
Image of page 4
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);
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern