Download presentation

Presentation is loading. Please wait.

Published byDiana Palmer Modified over 3 years ago

1
Lecture 10: Don't Reinvent the Wheel

2
Exam Results

3
Homework #3 Due on Monday, March 2, 2009 -- 8:00pm Exclusive OR logic (XOR) A XOR B = ((A && !B) || (!A && B)) B A http://hotjobs.yahoo.com/career-articles- wanted_you_10_jobs_where_employers_come_looking_ for_you-668 Software Engineer one of 10 hot jobs

4
Using Functions Easy management of large program development Programs solving real-world problems are large. Solution: divide-and-conquer Construct a large program from smaller pieces or modules. Each piece is more manageable. Modules in C are called functions. YearOperating SystemSLOC (Million) 1993Windows NT 3.14-5 1994Windows NT 3.57-8 1996Windows NT 4.011-12 2000Windows 2000more than 29 2001Windows XP40 2003Windows Server 200350 Operating SystemSLOC (Million) Red Hat Linux 6.217 Red Hat Linux 7.130 OpenSolaris9.7 FreeBSD8.8 Mac OS X 10.486 Linux kernel 2.6.05.2 SLOC: source lines of code

5
Using Functions Avoid re-inventing the wheel Using existing functions as building-blocks to create new programs “Prepackaged” functions in the C Standard Library can be used. User-defined functions can also be used.

6
C Standard Library A rich collection of functions Common mathematical calculations String manipulations Character manipulations Input/output Others Provide many of the capabilities one need. http://en.wikipedia.org/wiki/C_standard_library

7
Function Calls Invoking functions (by a function call) Provide function name and arguments (data) Function performs operations or manipulations Function returns results A common analogy of function call: Boss asks worker to complete a task. Worker gets information, does task, returns result. Information hiding: boss does not know details. Hierarchical boss function/worker function relationship The calling function, or caller The called function, or callee

8
Math Library Functions Math library functions Perform common mathematical calculations #include While compiling, use the option -lm to link the math library. Format for calling functions FunctionName( argument ); If multiple arguments, use comma-separated list Example printf(“%.2f”, sqrt( 900.0 )); Calls function sqrt, which returns the square root of its argument. All math functions return data type double. Arguments may be constants, variables, or expressions

9
Commonly Used Math Library Functions

11
Law of Cosines Leg 2 Leg 1 Hypotenuse

Similar presentations

Presentation is loading. Please wait....

OK

Programming Fundamentals Enumerations and Functions.

Programming Fundamentals Enumerations and Functions.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on job rotation process Ppt on preparedness for disaster in india Download ppt on conservation of water resources Download ppt on limits and derivatives Ppt on accounts payable process Ppt on our changing earth for class 7 Ppt on cross-sectional study examples Mis ppt on hospitality Free download ppt on sources of energy for class 10 Ppt on principles of object-oriented programming interview questions