class_notes7

Each program contains a number of functions one of

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: – Functions • All C programs are made up of components (modules) called functions. Each program contains a number of functions, one of which is called main. • C contains libraries of prewritten functions, and also allows users to write their own functions. • When using library functions, a statement telling C to use the library must be included in the header – Example: #include <math.h> • Many mathematical functions are available in the C math library. Math Library Functions • Math library functions – Perform common mathematical calculations (sin, exponent, absolute value, etc.) – Include in header: #include <math.h> • Format for calling functions – FunctionName( argument1 , argument2, … ); – Arguments may be constants, variables, or expressions – i = sqrt( 25.0 ); • sqrt is a function that accepts 1 argument of data type double • sqrt calculates the square root of the argument (in this case 25.0) • All math functions...
View Full Document

This note was uploaded on 08/06/2010 for the course ENGR 3 taught by Professor Ben-yaakov during the Summer '08 term at UCSB.

Ask a homework question - tutors are online