SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Loops
Repeating Code Multiple Times
Svetlin Nakov
Technical Trainer
www.nakov.com
Software University
http://softuni.bg
Table of Contents
1. What is a Loop?
2. Loops in C#
 while loops
 do … while loops
 for loops
 foreach loops
3. Special loop operators
 break, continue, goto
4. Nested loops
2
Loop: Definition
 A loop is a control statement that repeats the execution of a
block of statements
 May execute a code block fixed number of times
 May execute a code block while given condition holds
 May execute a code block for each member of a collection
 Loops that never end are called an infinite loops
while (condition)
{
statements;
}
3
Using while(…) Loop
Repeating a Statement While
Certain Condition Holds
How To Use While Loop?
 The simplest and most frequently used loop
 The repeat condition
 Returns a boolean result of true or false
 Also called loop condition
while (condition)
{
statements;
}
5
While Loop: How It Works?
true
statement
false
condition
6
While Loop – Example
int counter = 0;
while (counter < 10)
{
Console.WriteLine("Number : {0}", counter);
counter++;
}
7
while(…) Loop
Examples
 Calculate and print the sum of the first N natural numbers
Sum 1..N – Example
Console.Write("n = ");
int n = int.Parse(Console.ReadLine());
int number = 1;
int sum = 1;
Console.Write("The sum 1");
while (number < n)
{
number++;
sum += number ;
Console.Write("+{0}", number);
}
Console.WriteLine(" = {0}", sum);
9
Calculating Sum 1..N
Live Demo
Prime Number Check – Example
Console.Write("Enter a positive integer number: ");
uint number = uint.Parse(Console.ReadLine());
uint divider = 2;
uint maxDivider = (uint) Math.Sqrt(number);
bool prime = true;
while (prime && (divider <= maxDivider))
{
if (number % divider == 0)
{
prime = false;
}
divider++;
}
Console.WriteLine("Prime? {0}", prime);
11
Checking Whether a
Number Is Prime
Live Demo
Using the break Operator
 The break operator exits the inner-most loop
static void Main()
{
int n = Convert.ToInt32(Console.ReadLine());
// Calculate n! = 1 * 2 * ... * n
int result = 1;
while (true)
{
if (n == 1)
break;
result *= n;
n--;
}
Console.WriteLine("n! = " + result);
}
13
Calculating Factorial
Live Demo
do { … }
while (…)
Loop
Using Do-While Loop
 Another classical loop structure is:
 The block of statements is repeated
 While the boolean loop condition holds
 The loop is executed at least once
do
{
statements;
}
while (condition);
16
Do-While Statement: How It Works?
true
condition
statements
false
do { … }
while (…)
Examples
Calculating N Factorial – Example
static void Main()
{
string numberAsString = Console.ReadLine();
int n = Convert.ToInt32(numberAsString);
int factorial = 1;
do
{
factorial *= n;
n--;
}
while (n > 0);
Console.WriteLine("n! = " + factorial);
}
19
using System.Numerics;
static void Main()
{
int n = 1000;
BigInteger factorial = 1;
do
{
factorial *= n;
n--;
}
while (n > 0);
Console.WriteLine("n! = " + factorial);
}
Don't forget to add a reference to
System.Numerics.dll.
Factorial with BigInteger – Example
20
Factorial (do ... while)
Live Demo
22
 Calculating the product of all numbers in the interval [n..m]:
Product of Numbers [N..M] – Example
int n = int.Parse(Console.ReadLine());
int m = int.Parse(Console.ReadLine());
int number = n;
decimal product = 1;
do
{
product *= number;
number++;
}
while (number <= m);
Console.WriteLine("product[{0}..{1}] = {2}", n, m, product);
Product of the Numbers
in the Interval [n..m]
Live Demo
for Loops
 The typical for loop syntax is:
 Consists of
 Initialization statement
 Boolean test expression
 Update statement
 Loop body block
For Loops
for (initialization; test; update)
{
statements;
}
25
 The initialization expression
 Executed once, just before the loop is entered
 Like it is out of the loop, just before it
 Typically used to declare a counter variable
The Initialization Expression
for (int number = 0; ...; ...)
{
// Can use number here
}
// Cannot use number here (out of scope)
26
 The test expression is evaluated before each loop iteration
 If true, the loop body is executed
 If false, the loop finishes (and the loop body is skipped)
 Used as a loop condition
The Test Expression
for (int number = 0; number < 10; ...)
{
// Can use number here
}
// Cannot use number here (out of scope)
27
 The update expression
 Executed at each iteration after the body of the loop is finished
 Typically used to update the loop counter
 Can update multiple variables
The Update Expression
for (int number = 0; number < 10; number++)
{
// Can use number here
}
// Cannot use number here (out of scope)
28
for Loop
Examples
 A simple for-loop to print the numbers 0…9:
Simple for Loop – Example
for (int number = 0; number < 10; number++)
{
Console.Write(number + " ");
}
 A simple for-loop to calculate n!:
decimal factorial = 1;
for (int i = 1; i <= n; i++)
{
factorial *= i;
}
30
31
 A complex for-loop could have several counter variables:
Complex for Loop – Example
for (int i=1, sum=1; i<=128; i=i*2, sum+=i)
{
Console.WriteLine("i={0}, sum={1}", i, sum);
}
i=1, sum=1
i=2, sum=3
i=4, sum=7
i=8, sum=15
...
 Result:
For Loops
Live Demo
N^M – Example
 Calculating n to power m (denoted as n^m):
static void Main()
{
int n = int.Parse(Console.ReadLine());
int m = int.Parse(Console.ReadLine());
decimal result = 1;
for (int i=0; i<m; i++)
{
result *= n;
}
Console.WriteLine("n^m = " + result);
}
33
Calculating N^M
Live Demo
 continue bypasses the iteration of the inner-most loop
 Example: sum all odd numbers in [1…n], not divisors of 7:
Using the continue Operator
int n = int.Parse(Console.ReadLine());
int sum = 0;
for (int i = 1; i <= n; i += 2)
{
if (i % 7 == 0)
{
continue;
}
sum += i;
}
Console.WriteLine("sum = {0}", sum);
35
Using the continue Operator
Live Demo
foreach Loop
Iterating over a Collection
 The typical foreach loop syntax is:
 Iterates over all the elements of a collection
 The element is the loop variable that takes sequentially all
collection values
 The collection can be list, array or other group of elements of
the same type
For-Each Loops
foreach (var element in collection)
{
statements;
}
38
 Example of foreach loop:
 The loop iterates over the array of day names
 The variable day takes all its values
 Inside a foreach loop we cannot modify the current item
foreach Loop – Example
string[] days = {
"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday" };
foreach (var day in days)
{
Console.WriteLine(day);
}
39
foreach Loop
Live Demo
Nested Loops
Using a Loop Inside a Loop
 A composition of loops is called a nested loop
 A loop inside another loop
What Is Nested Loop?
for (initialization; test; update)
{
for (initialization; test; update)
{
statements;
}
…
}
42
Nested Loops
Examples
 Print the following triangle of numbers:
Triangle – Example
int n = int.Parse(Console.ReadLine());
for (int row = 1; row <= n; row++)
{
for (int column = 1; column <= row; column++)
{
Console.Write("{0} ", column);
}
Console.WriteLine();
}
1
1 2
…
1 2 3 … n
44
Triangle of Numbers
Live Demo
Primes in the Range [N … M] – Example
int n = int.Parse(Console.ReadLine());
int m = int.Parse(Console.ReadLine());
for (int number = n; number <= m; number++)
{
bool prime = true;
int divider = 2;
int maxDivider = Math.Sqrt(number);
while (divider <= maxDivider)
{
if (number % divider == 0)
{
prime = false;
break;
}
divider++;
}
if (prime)
Console.Write("{0} ", number);
}
46
Primes in the Range [n, m]
Live Demo
C# Jump Statements
 Jump statements are:
 break, continue, goto
 How continue woks?
 In while and do-while loops jumps to the test expression
 In for loops jumps to the update expression
 To exit the most-inner loop use break
 To exit from an outer loop use goto with a label
 Note: avoid using goto! (it is considered harmful)
48
C# Jump Statements – Example
int outerCounter = 0;
for (int outer = 0; outer < 10; outer++)
{
for (int inner = 0; inner < 10; inner++)
{
if (inner % 3 == 0)
continue;
if (outer == 7)
break;
if (inner + outer > 9)
goto breakOut;
}
outerCounter++;
}
breakOut:Label
49
Loops: More Examples
Nested Loops – Examples
 Print all four digit numbers in format ABCD such that A+B = C+D
(known as happy numbers)
static void Main()
{
for (int a = 1; a <= 9; a++)
for (int b = 0; b <= 9; b++)
for (int c = 0; c <= 9; c++)
for (int d = 0; d <= 9; d++)
if (a + b == c + d)
Console.WriteLine("{0}{1}{2}{3}", a, b, c, d);
}
Can you improve
this algorithm to use
only 3 nested loops?
51
Happy Numbers
Live Demo
Nested Loops – Examples
 Print all combinations from TOTO 6/49 lottery
static void Main()
{
int i1, i2, i3, i4, i5, i6;
for (i1 = 1; i1 <= 44; i1++)
for (i2 = i1 + 1; i2 <= 45; i2++)
for (i3 = i2 + 1; i3 <= 46; i3++)
for (i4 = i3 + 1; i4 <= 47; i4++)
for (i5 = i4 + 1; i5 <= 48; i5++)
for (i6 = i5 + 1; i6 <= 49; i6++)
Console.WriteLine("{0} {1} {2} {3} {4} {5}",
i1, i2, i3, i4, i5, i6);
}
Warning: the execution
of this code could take
a very long time.
53
TOTO 6/49
Live Demo
55
 C# supports four types of loops:
 while loops
 do-while loops
 for loops
 foreach loops
 Nested loops are used to implement more complex logic
 The operators continue, break & goto can change the
default loop execution behavior
Summary
?
http://softuni.bg/courses/csharp-basics/
Loops: Repeating Code Multiple Times
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
57
 Attribution: this work may contain portions from
 "Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license
 "C# Part I" course by Telerik Academy under CC-BY-NC-SA license
Free Trainings @ Software University
 Software University Foundation – softuni.org
 Software University – High-Quality Education,
Profession and Job for Software Developers
 softuni.bg
 Software University @ Facebook
 facebook.com/SoftwareUniversity
 Software University @ YouTube
 youtube.com/SoftwareUniversity
 Software University Forums – forum.softuni.bg

Weitere ähnliche Inhalte

Was ist angesagt?

03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statementsIntro C# Book
 
Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQIntro C# Book
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and ClassesIntro C# Book
 
04. Console Input Output
04. Console Input Output 04. Console Input Output
04. Console Input Output Intro C# Book
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queuesIntro C# Book
 
13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processingIntro C# Book
 
Java Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedJava Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedSvetlin Nakov
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variablesIntro C# Book
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks QueuesIntro C# Book
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexityIntro C# Book
 
15. Streams Files and Directories
15. Streams Files and Directories 15. Streams Files and Directories
15. Streams Files and Directories Intro C# Book
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm ComplexityIntro C# Book
 
Java Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsJava Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsSvetlin Nakov
 
Ch02 primitive-data-definite-loops
Ch02 primitive-data-definite-loopsCh02 primitive-data-definite-loops
Ch02 primitive-data-definite-loopsJames Brotsos
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classesIntro C# Book
 
Java Foundations: Arrays
Java Foundations: ArraysJava Foundations: Arrays
Java Foundations: ArraysSvetlin Nakov
 

Was ist angesagt? (20)

03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
 
Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQ
 
05. Java Loops Methods and Classes
05. Java Loops Methods and Classes05. Java Loops Methods and Classes
05. Java Loops Methods and Classes
 
04. Console Input Output
04. Console Input Output 04. Console Input Output
04. Console Input Output
 
09. Methods
09. Methods09. Methods
09. Methods
 
16. Java stacks and queues
16. Java stacks and queues16. Java stacks and queues
16. Java stacks and queues
 
13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processing
 
Java Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedJava Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting Started
 
02. Data Types and variables
02. Data Types and variables02. Data Types and variables
02. Data Types and variables
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
15. Streams Files and Directories
15. Streams Files and Directories 15. Streams Files and Directories
15. Streams Files and Directories
 
19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity19. Data Structures and Algorithm Complexity
19. Data Structures and Algorithm Complexity
 
Java Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsJava Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, Loops
 
Ch02 primitive-data-definite-loops
Ch02 primitive-data-definite-loopsCh02 primitive-data-definite-loops
Ch02 primitive-data-definite-loops
 
11. Java Objects and classes
11. Java  Objects and classes11. Java  Objects and classes
11. Java Objects and classes
 
Java Foundations: Arrays
Java Foundations: ArraysJava Foundations: Arrays
Java Foundations: Arrays
 
Parameters
ParametersParameters
Parameters
 

Ähnlich wie Loops: Repeating Code Multiple Times

Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6Vince Vo
 
Control structures ii
Control structures ii Control structures ii
Control structures ii Ahmad Idrees
 
Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingNeeru Mittal
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)jahanullah
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05IIUM
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops Hemantha Kulathilake
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptxMrhaider4
 
1.3 core programming [identify the appropriate method for handling repetition]
1.3 core programming [identify the appropriate method for handling repetition]1.3 core programming [identify the appropriate method for handling repetition]
1.3 core programming [identify the appropriate method for handling repetition]tototo147
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition StructurePRN USM
 
Lec7 - Loops updated.pptx
Lec7 - Loops updated.pptxLec7 - Loops updated.pptx
Lec7 - Loops updated.pptxNaumanRasheed11
 

Ähnlich wie Loops: Repeating Code Multiple Times (20)

06 Loops
06 Loops06 Loops
06 Loops
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Iteration
IterationIteration
Iteration
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
 
Iterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop workingIterative control structures, looping, types of loops, loop working
Iterative control structures, looping, types of loops, loop working
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
130707833146508191
130707833146508191130707833146508191
130707833146508191
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
Loops
LoopsLoops
Loops
 
Algorithms with-java-1.0
Algorithms with-java-1.0Algorithms with-java-1.0
Algorithms with-java-1.0
 
Thread
ThreadThread
Thread
 
COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops COM1407: Program Control Structures – Repetition and Loops
COM1407: Program Control Structures – Repetition and Loops
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
1.3 core programming [identify the appropriate method for handling repetition]
1.3 core programming [identify the appropriate method for handling repetition]1.3 core programming [identify the appropriate method for handling repetition]
1.3 core programming [identify the appropriate method for handling repetition]
 
Repetition Structure
Repetition StructureRepetition Structure
Repetition Structure
 
Loops (1)
Loops (1)Loops (1)
Loops (1)
 
Lec7 - Loops updated.pptx
Lec7 - Loops updated.pptxLec7 - Loops updated.pptx
Lec7 - Loops updated.pptx
 

Mehr von Intro C# Book

17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversalIntro C# Book
 
Java Problem solving
Java Problem solving Java Problem solving
Java Problem solving Intro C# Book
 
21. Java High Quality Programming Code
21. Java High Quality Programming Code21. Java High Quality Programming Code
21. Java High Quality Programming CodeIntro C# Book
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism Intro C# Book
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstractionIntro C# Book
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulationIntro C# Book
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritanceIntro C# Book
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arraysIntro C# Book
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classesIntro C# Book
 
01. Introduction to programming with java
01. Introduction to programming with java01. Introduction to programming with java
01. Introduction to programming with javaIntro C# Book
 
23. Methodology of Problem Solving
23. Methodology of Problem Solving23. Methodology of Problem Solving
23. Methodology of Problem SolvingIntro C# Book
 
21. High-Quality Programming Code
21. High-Quality Programming Code21. High-Quality Programming Code
21. High-Quality Programming CodeIntro C# Book
 
18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and Set18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and SetIntro C# Book
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like StructuresIntro C# Book
 

Mehr von Intro C# Book (16)

17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
 
Java Problem solving
Java Problem solving Java Problem solving
Java Problem solving
 
21. Java High Quality Programming Code
21. Java High Quality Programming Code21. Java High Quality Programming Code
21. Java High Quality Programming Code
 
20.5 Java polymorphism
20.5 Java polymorphism 20.5 Java polymorphism
20.5 Java polymorphism
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
20.2 Java inheritance
20.2 Java inheritance20.2 Java inheritance
20.2 Java inheritance
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
 
14. Java defining classes
14. Java defining classes14. Java defining classes
14. Java defining classes
 
01. Introduction to programming with java
01. Introduction to programming with java01. Introduction to programming with java
01. Introduction to programming with java
 
23. Methodology of Problem Solving
23. Methodology of Problem Solving23. Methodology of Problem Solving
23. Methodology of Problem Solving
 
21. High-Quality Programming Code
21. High-Quality Programming Code21. High-Quality Programming Code
21. High-Quality Programming Code
 
18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and Set18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and Set
 
17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
 
14 Defining Classes
14 Defining Classes14 Defining Classes
14 Defining Classes
 

Kürzlich hochgeladen

Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 

Kürzlich hochgeladen (20)

Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 

Loops: Repeating Code Multiple Times

  • 1. Loops Repeating Code Multiple Times Svetlin Nakov Technical Trainer www.nakov.com Software University http://softuni.bg
  • 2. Table of Contents 1. What is a Loop? 2. Loops in C#  while loops  do … while loops  for loops  foreach loops 3. Special loop operators  break, continue, goto 4. Nested loops 2
  • 3. Loop: Definition  A loop is a control statement that repeats the execution of a block of statements  May execute a code block fixed number of times  May execute a code block while given condition holds  May execute a code block for each member of a collection  Loops that never end are called an infinite loops while (condition) { statements; } 3
  • 4. Using while(…) Loop Repeating a Statement While Certain Condition Holds
  • 5. How To Use While Loop?  The simplest and most frequently used loop  The repeat condition  Returns a boolean result of true or false  Also called loop condition while (condition) { statements; } 5
  • 6. While Loop: How It Works? true statement false condition 6
  • 7. While Loop – Example int counter = 0; while (counter < 10) { Console.WriteLine("Number : {0}", counter); counter++; } 7
  • 9.  Calculate and print the sum of the first N natural numbers Sum 1..N – Example Console.Write("n = "); int n = int.Parse(Console.ReadLine()); int number = 1; int sum = 1; Console.Write("The sum 1"); while (number < n) { number++; sum += number ; Console.Write("+{0}", number); } Console.WriteLine(" = {0}", sum); 9
  • 11. Prime Number Check – Example Console.Write("Enter a positive integer number: "); uint number = uint.Parse(Console.ReadLine()); uint divider = 2; uint maxDivider = (uint) Math.Sqrt(number); bool prime = true; while (prime && (divider <= maxDivider)) { if (number % divider == 0) { prime = false; } divider++; } Console.WriteLine("Prime? {0}", prime); 11
  • 12. Checking Whether a Number Is Prime Live Demo
  • 13. Using the break Operator  The break operator exits the inner-most loop static void Main() { int n = Convert.ToInt32(Console.ReadLine()); // Calculate n! = 1 * 2 * ... * n int result = 1; while (true) { if (n == 1) break; result *= n; n--; } Console.WriteLine("n! = " + result); } 13
  • 15. do { … } while (…) Loop
  • 16. Using Do-While Loop  Another classical loop structure is:  The block of statements is repeated  While the boolean loop condition holds  The loop is executed at least once do { statements; } while (condition); 16
  • 17. Do-While Statement: How It Works? true condition statements false
  • 18. do { … } while (…) Examples
  • 19. Calculating N Factorial – Example static void Main() { string numberAsString = Console.ReadLine(); int n = Convert.ToInt32(numberAsString); int factorial = 1; do { factorial *= n; n--; } while (n > 0); Console.WriteLine("n! = " + factorial); } 19
  • 20. using System.Numerics; static void Main() { int n = 1000; BigInteger factorial = 1; do { factorial *= n; n--; } while (n > 0); Console.WriteLine("n! = " + factorial); } Don't forget to add a reference to System.Numerics.dll. Factorial with BigInteger – Example 20
  • 21. Factorial (do ... while) Live Demo
  • 22. 22  Calculating the product of all numbers in the interval [n..m]: Product of Numbers [N..M] – Example int n = int.Parse(Console.ReadLine()); int m = int.Parse(Console.ReadLine()); int number = n; decimal product = 1; do { product *= number; number++; } while (number <= m); Console.WriteLine("product[{0}..{1}] = {2}", n, m, product);
  • 23. Product of the Numbers in the Interval [n..m] Live Demo
  • 25.  The typical for loop syntax is:  Consists of  Initialization statement  Boolean test expression  Update statement  Loop body block For Loops for (initialization; test; update) { statements; } 25
  • 26.  The initialization expression  Executed once, just before the loop is entered  Like it is out of the loop, just before it  Typically used to declare a counter variable The Initialization Expression for (int number = 0; ...; ...) { // Can use number here } // Cannot use number here (out of scope) 26
  • 27.  The test expression is evaluated before each loop iteration  If true, the loop body is executed  If false, the loop finishes (and the loop body is skipped)  Used as a loop condition The Test Expression for (int number = 0; number < 10; ...) { // Can use number here } // Cannot use number here (out of scope) 27
  • 28.  The update expression  Executed at each iteration after the body of the loop is finished  Typically used to update the loop counter  Can update multiple variables The Update Expression for (int number = 0; number < 10; number++) { // Can use number here } // Cannot use number here (out of scope) 28
  • 30.  A simple for-loop to print the numbers 0…9: Simple for Loop – Example for (int number = 0; number < 10; number++) { Console.Write(number + " "); }  A simple for-loop to calculate n!: decimal factorial = 1; for (int i = 1; i <= n; i++) { factorial *= i; } 30
  • 31. 31  A complex for-loop could have several counter variables: Complex for Loop – Example for (int i=1, sum=1; i<=128; i=i*2, sum+=i) { Console.WriteLine("i={0}, sum={1}", i, sum); } i=1, sum=1 i=2, sum=3 i=4, sum=7 i=8, sum=15 ...  Result:
  • 33. N^M – Example  Calculating n to power m (denoted as n^m): static void Main() { int n = int.Parse(Console.ReadLine()); int m = int.Parse(Console.ReadLine()); decimal result = 1; for (int i=0; i<m; i++) { result *= n; } Console.WriteLine("n^m = " + result); } 33
  • 35.  continue bypasses the iteration of the inner-most loop  Example: sum all odd numbers in [1…n], not divisors of 7: Using the continue Operator int n = int.Parse(Console.ReadLine()); int sum = 0; for (int i = 1; i <= n; i += 2) { if (i % 7 == 0) { continue; } sum += i; } Console.WriteLine("sum = {0}", sum); 35
  • 36. Using the continue Operator Live Demo
  • 38.  The typical foreach loop syntax is:  Iterates over all the elements of a collection  The element is the loop variable that takes sequentially all collection values  The collection can be list, array or other group of elements of the same type For-Each Loops foreach (var element in collection) { statements; } 38
  • 39.  Example of foreach loop:  The loop iterates over the array of day names  The variable day takes all its values  Inside a foreach loop we cannot modify the current item foreach Loop – Example string[] days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; foreach (var day in days) { Console.WriteLine(day); } 39
  • 41. Nested Loops Using a Loop Inside a Loop
  • 42.  A composition of loops is called a nested loop  A loop inside another loop What Is Nested Loop? for (initialization; test; update) { for (initialization; test; update) { statements; } … } 42
  • 44.  Print the following triangle of numbers: Triangle – Example int n = int.Parse(Console.ReadLine()); for (int row = 1; row <= n; row++) { for (int column = 1; column <= row; column++) { Console.Write("{0} ", column); } Console.WriteLine(); } 1 1 2 … 1 2 3 … n 44
  • 46. Primes in the Range [N … M] – Example int n = int.Parse(Console.ReadLine()); int m = int.Parse(Console.ReadLine()); for (int number = n; number <= m; number++) { bool prime = true; int divider = 2; int maxDivider = Math.Sqrt(number); while (divider <= maxDivider) { if (number % divider == 0) { prime = false; break; } divider++; } if (prime) Console.Write("{0} ", number); } 46
  • 47. Primes in the Range [n, m] Live Demo
  • 48. C# Jump Statements  Jump statements are:  break, continue, goto  How continue woks?  In while and do-while loops jumps to the test expression  In for loops jumps to the update expression  To exit the most-inner loop use break  To exit from an outer loop use goto with a label  Note: avoid using goto! (it is considered harmful) 48
  • 49. C# Jump Statements – Example int outerCounter = 0; for (int outer = 0; outer < 10; outer++) { for (int inner = 0; inner < 10; inner++) { if (inner % 3 == 0) continue; if (outer == 7) break; if (inner + outer > 9) goto breakOut; } outerCounter++; } breakOut:Label 49
  • 51. Nested Loops – Examples  Print all four digit numbers in format ABCD such that A+B = C+D (known as happy numbers) static void Main() { for (int a = 1; a <= 9; a++) for (int b = 0; b <= 9; b++) for (int c = 0; c <= 9; c++) for (int d = 0; d <= 9; d++) if (a + b == c + d) Console.WriteLine("{0}{1}{2}{3}", a, b, c, d); } Can you improve this algorithm to use only 3 nested loops? 51
  • 53. Nested Loops – Examples  Print all combinations from TOTO 6/49 lottery static void Main() { int i1, i2, i3, i4, i5, i6; for (i1 = 1; i1 <= 44; i1++) for (i2 = i1 + 1; i2 <= 45; i2++) for (i3 = i2 + 1; i3 <= 46; i3++) for (i4 = i3 + 1; i4 <= 47; i4++) for (i5 = i4 + 1; i5 <= 48; i5++) for (i6 = i5 + 1; i6 <= 49; i6++) Console.WriteLine("{0} {1} {2} {3} {4} {5}", i1, i2, i3, i4, i5, i6); } Warning: the execution of this code could take a very long time. 53
  • 55. 55  C# supports four types of loops:  while loops  do-while loops  for loops  foreach loops  Nested loops are used to implement more complex logic  The operators continue, break & goto can change the default loop execution behavior Summary
  • 57. License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license 57  Attribution: this work may contain portions from  "Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license  "C# Part I" course by Telerik Academy under CC-BY-NC-SA license
  • 58. Free Trainings @ Software University  Software University Foundation – softuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg  Software University @ Facebook  facebook.com/SoftwareUniversity  Software University @ YouTube  youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bg

Hinweis der Redaktion

  1. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  2. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  3. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  4. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  5. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  6. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  7. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  8. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  9. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  10. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  11. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  12. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  13. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  14. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  15. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  16. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  17. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  18. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  19. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  20. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  21. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  22. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  23. (c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*