New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here


by: Freida Schaefer DDS


Freida Schaefer DDS
GPA 3.68

Y. Liang

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Y. Liang
Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 5 page Class Notes was uploaded by Freida Schaefer DDS on Saturday October 3, 2015. The Class Notes belongs to CSCI 1301 at Armstrong Atlantic State University taught by Y. Liang in Fall. Since its upload, it has received 36 views. For similar materials see /class/217868/csci-1301-armstrong-atlantic-state-university in ComputerScienence at Armstrong Atlantic State University.




Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/03/15
Chapter 4 Loops 1 count lt lOO always true at Point A count lt lOO always false at Point C count lt lOO is sometimes true or sometimes false at Point B 2 It would be wrong if it is initialized to a value between 9 and 100 because it could be the number you attempt to guess 3 a In nite number of times b The loop body is executed nine times The printout is 2 4 6 8 on separate lines c The loop body is executed nine times The printout is 3 5 7 9 on separate lines 4 The difference between a do whi l e loop and a wni l e loop is the order of evaluating the continuation condition and executing the loop body In a while loop the continuation condition is checked and then iftrue the loop body is executed In a do whi l e loop the loop body is executed for the first time before the continuation condition is evaluated int sum 039 int number 211 gtgt number39 E i Sum number39 211 gtgt number39 while number 1 0 5 Same When the i and i are used in isolation their effects are same 6 The three parts in a for loop control are as follows The first part initializes the control variable The second part is a Boolean expression that determines whether the loop will repeat The third part is the adjustment statement which adjusts the control variable 7 The loop keeps doing something indefinitely 8 No The scope ofthe variable is inside the loop maX is 5 number 0 sum is 14 count is 4 maX is 5 number 0 Yes The advantages of f or loops are simplicity and readability Compilers can produce more ef cient code for the f or loop than for the corresponding whi 1 e loop while loop long sum 0 int i 0 while i lt 1000 1 sum i do whileloop long sum 0 int i 0 do i While i lt 1000 sum i No Try nl 3 and n2 3 The keyword break is used to eXit the current loop The program in A will terminate The output is Balance is 1 The keyword continue causes the rest ofthe loop body to be skipped for the current iteration The whi 1 e loop will not terminate in B for int i 1 sum lt 10000 i sum sum i 17 If a continue statement is executed inside a for loop the rest of the iteration is skipped then the actionaftereachiteration is performed and the loopcontinuation condition is checked If a continue statement is executed inside a while loop the rest of the iteration is skipped then the loopcontinuationcondition is checked Here is the x int i 0 While i lt 4 i continue sum i i 18 1nclude lt1ostreamgt using namespace std39 int main i int sum 039 int number 039 while number lt 20 ampamp Sum lt 100 i number39 sum number39 4 cout ltlt quotThe number 15 quot ltlt number ltlt endl39 cout ltlt quotThe Sum 15 quot ltlt Sum ltlt endl39 return 039 i 1nclude lt1ostreamgt using namespace std39 int main i int sum 039 int number 039 whlle number lt 20 number 1f number 1 10 ampamp number 1 11 Sum number39 1 cout ltlt quotThe Sum 15 quot ltlt Sum39 return 039 1 19 a Line 1 The semicolon at the end of the for loop heading should be removed Line 4 the semicolon at the end of the if statement should be removed Line 5 Missing a semicolon for the rst println statement Line 9 The semicolon at the end of the while heading should be removed Line 17 Missing a semicolon at the end ofthe dowhile loop b The loop will be executed only one time because the test condition for the while clause is true 20 Tip for tracing programs Draw a table to see how variables change in the program Consider a for example i j output 1 0 0 1 1 2 0 0 2 1 1 2 2 3 0 0 3 1 1 3 2 2 3 3 4 0 0 4 1 1 4 2 2 4 3 3 4 4 A 0010120123 13 2L C D 2 3 2 1XXX2XXX4XXX8XXX16XXX 1XXX2XXX4XXX8XXX 1XXX2XXX4XXX IXXXZXXX IXXX lG 163G lGBGSG lGBGSG7G lGBGSG7G9G x is 2147483648 The reason When a variable is assigned a value that is too large in size to be stored 22 it causes overflow 2l47483647 l is actually 214M83648 A n times 13 n times C n 5 times D The ceiling of n 53 times


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Kyle Maynard Purdue

"When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the I made $280 on my first study guide!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.