CSC 160 CSC 160 Computer Programming Computer Programming for Non-Majors for Non-Majors Lecture #3: Calling Functions Lecture #3: Calling Functions Prof. Adam M. Wittenstein Prof. Adam M. Wittenstein [email protected][email protected]http://www.adelphi.edu/~wittensa/csc160/ http://www.adelphi.edu/~wittensa/csc160/
23
Embed
CSC 160 Computer Programming for Non-Majors Lecture #3: Calling Functions Prof. Adam M. Wittenstein [email protected]/csc160
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
The online book explanation may confuse some ofyou. That is okay. Here is what you need to know…● Pi (3.14…..) and Square Root of 2 (1.41….) are two
examples of numbers where the digits continue without a pattern.
● Since we cannot go on writing indefinitely, we round them off to just a few decimal places, say 3.14 or 1.4.
● When Scheme has rounded a number, it puts #i before the number.
II. Using DrSchemeII. Using DrScheme
Using DrScheme
Set to “Simply Scheme”
For most of the semester, we will use the SimplyScheme language level. If it is changed (e.g., you areusing a public computer on campus), use these stepsto restore Simply Scheme mode:
● Select Choose Language... from the Languages menu. A dialog box appears with a choice control (a.k.a. ``pop-up menu'') at the top.
● Choose the Simply Scheme language from the hierarchical choice list, then click OK.
Set to “Simply Scheme”
● Click the Run button. After clicking Run, the lower window indicates that the current language is Simply Scheme.
● You need to set the language level only once until you (or someone else using DrScheme on your computer) change languages. When you quit and restart DrScheme, the language setting is preserved.
Using the two windows
● The top area, the definitions window, is for defining new programs. We'll explain how to use this window next week.
● The bottom area, the interactions window, is for using programs once they are defined.
● Fortunately, Simply Scheme already has some programs written inside of it for us to use. Some examples are +, - , *, /, first, and sentence.
● To find 3 + 4, type it into the interactions window the Scheme way: (+ 3 4). After hitting enter, you should get 7.
Example 1: Translation
For each mathematical expression given below,
a) find its answer using paper and pen (or a calculator).
b) translate it into Scheme notation.
c) type into DrScheme’s interactions window and verify that the answer is what you expect.