Lecture4 - Beginning C for Engineers Spring 2008 Spring...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Beginning C for Engineers Spring 2008 Spring 2008 Lecture 4 Introduction Real-world problems- large & complex Best programming solution: Divide and conquer strategy Divide a large task into smaller tasks under the control of the main program 2/6/2008 RPI- csci1190 2 the control of the main program. Each smaller task is associated with a subprogram - module Some of the subprograms may be called by the main, some by other subprograms. Each subprogram may require multiple inputs to do its job and may return multiple outputs . Functions Program modules in C 1. Prepackaged functions - C Standard Library: rich collection of functions to make your job easier .e.g. 2/6/2008 RPI- csci1190 3 printf (%.2f, sqrt(900)); 2. Programmer-defined functions: functions you write, e.g. y = myfunction ( a, b, c); Functions Functions modularize your program so that your program is: easier to understand 2/6/2008 RPI- csci1190 4 easier to understand. easier to debug. easier to change later on . Functions Local variables - All variables defined in function definition. Known only to the function defined in. 2/6/2008 RPI- csci1190 5 Most functions have a list of parameters. parameters are for communicating info between functions. Function Definition General format of a function definition: return-value-type function-name (parameter list) { definitions 2/6/2008 RPI- csci1190 6 definitions statements } function-name: any valid identifier return-value-type : the type of data that function returns Function Definition If a function does not return anything then the return-type is void ....
View Full Document

Page1 / 29

Lecture4 - Beginning C for Engineers Spring 2008 Spring...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online