CMPT 166 Lecture Notes - Lecture 16: Global Variable, Local Variable, Ellipse

20 views7 pages

Document Summary

In these notes you will learn: the terminology for describing and using functions in processing, how to write a variety of simple functions in processing, what a void function is, the difference between local and global variables. You are no doubt familiar with functions from mathematics. Functions in processing are, essentially, a more general-purpose version of mathematical functions. They have many similarities, but also some important differences. In mathematics, a function is a rule that pairs an input value with an output value. For example, in math we can define a function ff like this: f(x)=x2f(x)=x2. This function is named f, and it takes a single number as input called xx. For example, f(5)=5 5=25f(5)=5 5=25, and we would say that f(5)f(5) evaluates to 25. We can also use it within expressions, such as 2+3f(2)2+3f(2), which evaluates to 14. Now lets write the equivalent of ff in processing: float f(float x) return x * x;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents