Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\unit3_top.gif

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\link_bar_top.gif

 Announcements

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate2.gif

 Unit3 deals with the control structures that allow us to program repetition of several statements in a way controllable by the inputs to the program.  These structures are also called loops ( while loops, do while loops, for loops etc. ).  This material is very basic and important. You will need it and use it continually from this point onward. You must make every effort to learn it well.

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate2.gif

 Reading Assignments

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate2.gif

Mandatory:  Book 1;  Pages 109- 131 & 138 - 149 

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate2.gif

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate.gif

 Subtopics — Notes/ Examples:


Loops classified by structure type:

  • while ( condition ) ….{ statements }
  • do .. { statements } …..while ( condition )
  • for ( initialization ; condition ; update ) … { statements }

Loops classified by utility:

 

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate.gif

 Tasks:

 

  • Write a program which calculates the average of several test scores entered through the keyboard. The sentinel value -1 should terminate the loop. Your program should count the number of the scores entered.
  • Write a program which calculates the product of   1*2*3*……..*34.  This product is called  "factorial of 34" and it is written as  34!
  • Start working on HW3 and PA3.

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate.gif

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate2.gif

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\link_bar_top.gif

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate2.gif

Description: Description: C:\Users\jyk0\Desktop\EMAweb\images\separate.gif

Jacob Y. Kazakia © 2001 All rights reserved