Download presentation
Presentation is loading. Please wait.
Published byJessica Richards Modified over 9 years ago
1
1 st Semester 2005 1 Module4-1 Iteration statement - while อภิรักษ์ จันทร์สร้าง Aphirak Jansang aphirak.j@ku.ac.th http://www.cpe.ku.ac.th/~aphirak Computer Engineering Department Kasetsart University, Bangkok THAILAND
2
1 st Semester 2005 2/39 Outline Review condition statement Loop statements while statement do…while statement for statement break statement
3
1 st Semester 2005 3/39 Simple C# Structure Namespace Class Main()Namespace Class Main() Variable & Constant Location statements WriteLine, ReadLine, if, switch, Loop Review condition statement
4
1 st Semester 2005 4/39 Condition Statements condition if (condition) statement; condition if (condition) statement1; else statement2; ( ) switch ( ) { case : ; break; default: ; break; } Review condition statement
5
1 st Semester 2005 5/39 Outline Review condition statement Loop statements while statement do…while statement for statement break statement
6
1 st Semester 2005 6/39 Loop or Iteration in C# for while do…while foreach Iteration Loop statements
7
1 st Semester 2005 7/39 Simple C# Program Start statement1 End statement1 Loop statements
8
1 st Semester 2005 8/39 Simple C# Program with Loop Start x=5; statement1 x=x-1; End x>0 true false Loop statements
9
1 st Semester 2005 9/39 Outline Review condition statement Loop statements while statement do…while statement for statement break statement
10
1 st Semester 2005 10/39 while statement condition statement true false while (condition) statement; while statement
11
1 st Semester 2005 11/39 Iteration Template Counter Controlled Sentinel Controlled while statement
12
1 st Semester 2005 12/39 Example3: Count Controlled Display 1 – 7 on screen initial counter statement; dec||inc counter condition true false See demo program!!!! prog4-loop.cs while statement: counter controlled
13
1 st Semester 2005 13/39 Iteration Template Counter Controlled Sentinel Controlled while statement
14
1 st Semester 2005 14/39 Example4: Sentinel Controlled Find summation from user input Exit program when user input negative number See demo program!!!! prog5-loop.cs while statement: sentinel controlled
15
1 st Semester 2005 15/39 Example 5: Display n stars See demo program!!!! prog6-loop.cs while statement: example
16
1 st Semester 2005 16/39 Example 6: Display stars See demo!!!! prog7-loop.cs while statement: example
17
1 st Semester 2005 17/39 Summary Loop statements while statement do…while statement for statement break statement
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.