DOC PREVIEW
TRINITY CSCI 1320 - Loop Examples

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Loop Examples9/24/20072Opening Discussion■Let's look at some solutions to the interclass problem.■I've added a new link on the links page for Project Euler. This site has a bunch of programming problems that are mathematically interesting over a range of difficulties. You know enough to do the easier ones now.■Departmental mailing lists. If you are thinking of majoring or minoring you should consider putting yourself on them.3Local static Variables■I was recently reminded of an obscure topics I forgot to cover when we did functions: local static variables.■The keyword static in C-family languages means something akin to “only one”.■As you know, normal local variables a created each time a method is called and destroyed when it returns so they have no memory of earlier calls.■Local static variables (declared with the keyword “static”) aren't like this. They are like global variables with a local scope. Only one of them is created no matter how many times the function is called and it remembers its value between calls.4Nested Loops■Loops are just statements and can be placed anywhere a statement goes. This includes inside of other loops or control structures.■When one loop appears inside of another the result is that the body of the inner loop is executed a multiplicative number of times.5Using Loops■Last time we introduced loops in C and ran through the simplest example we could with all three loop types to give you a feel for them.■Today we want to write some more significant code that involves loops. We can start by converting our calculator to a loop instead of using recursion. Then we can write some standard types of math functions.■If we have time we could write a function that doesn't have loops, but involves vector math.■We can also do some loops on input other than a menu.6Minute Essay■Which type of loop do you like best? Why?■Interclass Problem – Write a function double sumNums(int howMany) that reads the specified number of doubles and returns their sum. Include a main to test that it


View Full Document

TRINITY CSCI 1320 - Loop Examples

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Loop Examples
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Loop Examples and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Loop Examples 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?