W13-Struct_Func1

W13-Struct_Func1 - Functions 1 1 We've Already Use...

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

View Full Document Right Arrow Icon
10/24/05 1 Functions 1 10/24/05 2 We’ve Already Use Functions • int main(void) • printf(arg1, arg2, …) • scanf(arg1, arg2, …) • sqrt(arg1) • rand() • time(NULL) 10/24/05 3 What Is a Function? A request to: 1. Go to another part of your program (Function Call). 2. Perform a calculation or some other useful service (Function Execution). 3. Return and continue with the C code after the call (Function Return).
Background image of page 1

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

View Full DocumentRight Arrow Icon
10/24/05 4 Three Ways to Use Functions x = function1(arg1, arg2); takes arguments, returns a value. function2(arg1,arg2); takes arguments, returns nothing. function3(); takes no arguments, returns nothing. Last two examples sometimes called subroutine (when nothing returned) 10/24/05 5 C Functions Three parts to writing functions 1 Declaration -- tell the compiler about the function (function prototype). 2 Definition -- write the code the function executes. 3 Call -- Call (use) the function to do some work. 10/24/05
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/28/2009 for the course CS 151 taught by Professor Staff during the Spring '08 term at Oregon State.

Page1 / 5

W13-Struct_Func1 - Functions 1 1 We've Already Use...

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

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