Chapter 3 -Part I - Lecture Notes

Chapter 3 -Part I - Lecture Notes - hapter unctions Chapter...

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

View Full Document Right Arrow Icon
Chapter        3         –          Functions       . Part I Ideas:  1. Functions are the result of a technique called: “Divide-and-Conquer” which allows the  construction of large programs from small pieces called functions   . 2. Writing a function is a three-step process:  a. function prototype b. function call c. function definition   3. Function prototype, tells the compiler:  a. the type of the data returned by the function {type of the result} b. the type of the parameters the function expects to receive c. the number the parameters d. The order in which the parameters are expected to be passed to the function. 4. The parameters    of a function are local    variables to that function. 5. Defining a function parameter    again as a local    variable in the function is a syntax    error. 6. A function that does not return anything has a  void  return-type. 7. If nothing is written for the return-value-type of the function, then the compiler assumes  it is  int 8. Even if  int  is assumed implicitly, always    write  int  explicitly when the return-value-type  expected is an integer. An exception to this rule is for function  main () , for which the  return-value-type can be omitted. 9. When the function has a return-value-type and the body of the function does not return  any value, an error is generated by the compiler. 10. When the return-value-type is  void  and the function returns a value, an error is  generated by the compiler.
Image of page 1

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

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