Beruflich Dokumente
Kultur Dokumente
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Output: Counter = 1
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Output: Counter = 1
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Example: Re-Writing 1-1000
(using a while loop)
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
}
Output: Counter = 1
Infinite Loops
Counter = 1
Counter = 1
Counter = 1
.
.
} Continue
forever
.
Problem Solved
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
Problem Solved
1
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
Output: Counter = 1
Problem Solved
2
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
// Remember, counter++ is the same as
// counter = counter + 1
Example: Re-Writing 1-1000
(using a while loop)
2
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
Problem Solved
2
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
Output: Counter = 2
Problem Solved
3
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
How does it end?
999
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
How does it end?
999
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
How does it end?
999
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
1000
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
How does it end?
1000
while (counter < 1000) {
printf(Counter = %d \n ,counter) ;
counter++;
}
How does it end?
Has format:
do {
0
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Example
(count from 1 to 3)
0
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Example
(count from 1 to 3)
1
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Example
(count from 1 to 3)
1
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Output: 1
Example
(count from 1 to 3)
1
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Example
(count from 1 to 3)
2
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Example
(count from 1 to 3)
2
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Output: 2
Example
(count from 1 to 3)
2
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Example
(count from 1 to 3)
3
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
3
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
Output: 3
Example
(count from 1 to 3)
3
do {
counter++;
printf(%d\n, counter);
} while (counter < 3);
now false, so loop is finished
Simple Rules