Lec9 - Lecture 9 Functions Library(header file functions...

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

View Full Document Right Arrow Icon
Lecture 9: User defined functions 1 Lecture 9 Functions Library (header file) functions math.h examples: a=sqrt(10.0); b=sin(3.14159); c=pow(a,b); iomanip.h examples: setw(12) setprecision(3) User Defined Functions
Image of page 1

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

View Full Document Right Arrow Icon
Lecture 9: User defined functions 2 User defined functions: Single-Result functions math.h functions are single-result functions You send the function information – called arguments- and it returns equal to a value Void functions You call the function - with or without information and it does something – e.g. a calculation, output etc. The function does not return a value. Can return information by changing the values of the arguments (more on this in Lecture 10)
Image of page 2
Lecture 9: User defined functions 3 Recommended syntax: The best way to create a function is to use a prototype at the top of the program file and a function definition at the bottom. #include<header files > //prototype for function type functionname(variabletype, variabletype..); void main() {
Image of page 3

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

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