Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

18
Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang

Transcript of Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Page 1: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Iteration Statements

CGS 3460, Lecture 18Feb 20, 2006Hen-I Yang

Page 2: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Previously… for statement Break, continue statement

Page 3: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Agenda

About quiz 1 goto statement Null statement

Page 4: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Questions about Quiz 1

Grading policy How does that affect your grade? Should you be alarmed? What do you need to do to better prepare

for quiz 2 Answer key to quiz 1 will be posted later

today.

Page 5: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Questions about Quiz 1How do quizzes affect your grade? (25) 80% or above: You'll get whatever you receive for

the homework  (40) 60% -- 79%: You'll get 90% of what you receive for

the homework  (11) 50% -- 59%: You'll get 80% of what you receive for

the homework  (3) 40% -- 49%: You'll get 60% of what you receive for

the homework  (1) 39% or below: you'll get 60% of what you receive for

the homework. (pending code review) Average: 73, Max: 96, Min: 31, 81.25% will get 90% of

above as scaling factor

Page 6: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Questions about Quiz 1

Should you be alarmed? If you get more than 80%, you’re probably ok. If majority of point deduction comes from

problem 1, you’re probably ok. If you get less than 50%, or if you lost more than

a combined of 10 points in problem 2 and 3, or loss 15 points in problem 4. There’s a warning sign.

How do you interpret the result of quiz 1

Page 7: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Questions about Quiz 1

What do you need to do to better prepare for quiz 2?

It’s not just homework, you have to understand the material.

Study all the materials I tell you will be in the quiz.

Do not randomly guess an answer, some questions bare penalties.

I’ll adopt a less strict penalty in grading policy starting from quiz 2.

Page 8: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Questions about Quiz 1How do I request regrading? There is a regrading request form that will be posted onli

ne later today. Fill it out electronically, and submit electronically to cgs3

[email protected] with subject [CGS3460] Quiz 1 regrading request

TA/grader will arrange to discuss with you. There is an explicit grading policy issued. Unless there a

re clear errors or problem with grades summation, random requests probably will not change your grade.

In case you request a second appeal, bring the same form to see me. I will not have the discussion until the form has already been discussed/signed by the TA/grader.

Page 9: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

A Glimpse of Quiz 2

What is in Quiz 2? Everything related to Homework2 Everything in the textbook up to Section 5-2 Everything listed on the “topics” page up to Feb 10

About Quiz 2 Bring Gator 1 ID 15 minutes starting 9:35 am sharp No electronic device of any sort is allowed To have homework 2 counted toward your grade, you

have to take quiz 2. Lecture will continue after the completion of the quiz

Page 10: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Miscellaneous/Update

Homework 2 ClarificationEPA and fuel efficiency calculationHow to print strings/tags/message properly usi

ng conversion specifications? print_string.c

Homework 1 will be returned later this week

Page 11: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Throw in the Towel

Break; Find it! Abort search User input causes stop Good for exiting in the middle Work on the innermost statement, only exits one level

Continue; Not interested. Skip the rest of the loop, and go directly to the next Remain inside the loop Continue can only be used for loop, not switch e.g. add 0 (from user’s input)

Page 12: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Throw in the Towel (II)

Goto: BAD BAD BAD idea

goto label;label: statement Bad habit from Basic Unstructured. Both break and continue are restricted, but not got

o Use goto to emulate break; Use goto for multi-level break? Spaghetti code (Hard to read, hard to modify)

return; exit();

to be discussed later

Page 13: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Null statement

; Empty loop body At the end of compound statement A line by itself to avoid confusion Putting ; after () in if, while or for will ends t

he statemen

Page 15: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

STAGE 3

We have discussed about the components/elements of the program

We talked about how to analyze/design a program.

You have been introduced to basic operators. You are now familiar with most frequently used

statements. Formatted input/output, expressions, selection and iteration.

You should be able to write descent C programs by now. (and you will, in homework 3)

Page 16: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

STAGE 3

We are moving on the more advance materials now.

Types: What are they, why are they important

Arrays: Tired of declaring 10 variables for 10 entries of the same thing?

Functions: How do we pack code segments into something more meaningful?

Pointers: Let the fun begins.

Page 17: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Summary

Goto statement Null statement

Page 18: Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.

Before you go

Read Chapter 6. Homework 2 due tomorrow (Feb 21,

Tuesday at 11:59 pm)