IOS-C day 4 (upper) and ios-c day 4
1. Use of the while loop structure;
2. Random Number acquisition;
3. Use of do... while loop body;
4. Use of the for loop structure;
5. What is the difference between break and continue;
1. Use of the while loop structure
// While Structure
// While (conditional expression ){
// Loop body;
//}
// Execution sequence: determines whether the condition expression is true. If the condition expression is true, execute the loop body. After the loop body is executed, determine whether the condition expression is true. If the condition expression is not true, jump out of the while loop;
// Endless loop:
// Int a = 5;
// While (a> 0 ){
// Printf ("Hello World! \ N ");
//}
// Print 5 times hello world:
// Int a = 5;
// While (a> 0 ){
// Printf ("Hello World! \ N ");
// --;
//}
// Printf ("END \ n ");
// Int a = 0;
// While (a <5 ){
// Printf ("% dHello World! \ N ", );
// A ++;
//}
// Int a = 0;
// While (a <= 100 ){
// Printf ("% d", );
// A ++;
//}
/// Int a = 100;
// While (a> = 0 ){
// Printf ("% d", );
// --;
//}
// Calculate 1 ~ Sum of 100:
// Int I = 1, sum = 0;
// While (I <= 100 ){
/// Sum + = I;
/// I ++;
// Sum + = I ++;
//}
// Printf ("sum = % d \ n", sum );
// Output 1 ~ Even number of 100:
// Method 1:
// Int I = 0;
// While (I <= 100 ){
// If (I % 2 ){
// Printf ("% d", I );
//}
// I ++;
//}
// Method 2:
// Int I = 0;
// While (I <= 100 ){
// Printf ("% d", I );
// I + = 2 ;''
//}
// Print 1 ~ Multiples of 7 between 100:
// Int I = 1;
// While (I <= 100 ){
// If (I % 7 = 0 ){
// Printf ("% d", I );
//}
// I ++;
//}
// Print 1 ~ The number of single digits is 7:
// Int I = 1;
// While (I <= 100 ){
// If (I % 10 = 7 ){
// Printf ("% d", I );
//}
// I ++;
//}
// Print 1 ~ The 10 digits between 100 are 7:
// Int I = 1;
// While (I <= 100 ){
// If (I/10 = 7 ){
// Printf ("% d", I );
//}
// I ++;
//}
// Print 1 ~ 100 is not a multiple of 7 and does not contain the number of 7:
// Int I = 1;
// While (1 <= 100 ){
// If (I % 7! = 0 & I % 10! = 7 & I/10! = 7 ){
// Printf ("% d", I );
//}
// I ++;
//
//
//}
// Int a = 0, B = 0;
// For (a = 1; a <= 100; a ++ ){
// Printf ("% d", );
// For (B = 1; B <= 10; B ++ ){
// Printf ("\ n ");
//}
//}
5. What is the difference between break and continue;
// For (int I = 1; I <10 ;){
// If (I = 4 ){
// Break;
//}
// Printf ("% d", I );
//}
// The break jumps out of the current layer loop. You can think of for as a loop.
// For (int I = 1; I <10; I ++ ){
// For (int j = 1; j <10; j ++ ){
// If (j = 4 ){
// Break;
//} Printf ("% d", j );
//} Printf ("\ n ");
//}
// Continue: Used in a loop
// Continue: end this loop
// Function: accelerate the execution of the loop
5. What is the difference between break and continue;
// For (int I = 1; I <10 ;){
// If (I = 4 ){
// Break;
//}
// Printf ("% d", I );
//}
// The break jumps out of the current layer loop. You can think of for as a loop.
// For (int I = 1; I <10; I ++ ){
// For (int j = 1; j <10; j ++ ){
// If (j = 4 ){
// Break;
//} Printf ("% d", j );
//} Printf ("\ n ");
//}
// Continue: Used in a loop
// Continue: end this loop
// Function: accelerate the execution of the loop