Содержание
- 2. Decision Statements If statement
- 3. Example int numerator, denominator; Console.WriteLine(“Enter two integer values for the numerator and denominator”); numerator = Convert.ToInt32(Console.ReadLine());
- 4. The statement body can include more than one statement but make sure they are group into
- 5. Nested if Statement Nested if statements occur when one if statement is nested within another if
- 6. if - else - if operator If a program requires a choice from one of many
- 8. Conditional Operator ?: There is a special shorthand syntax that gives the same result as if
- 9. Example max = x >= y ? x : y; which is the equivalent of if
- 10. Switch Statement This statement is similar to the if-else-if ladder but is clearer, easier to code
- 11. Example double num1, num2, result; char op; Console.WriteLine(“Enter number operator number \n”); num1 = Convert.ToInt32(Console.ReadLine()); op
- 12. Iterative Statements For statement While statement Do while statement Break statement Continue statement
- 13. For Statement A statement or block of statements may be repeated a known number of times
- 14. Example int x; for (x = 1; x Console.WriteLine(“{0}”, x); The above example prints out the
- 15. Advanced for Loops for( x = 0, sum = 0; x { Console.WriteLine(“{0}”, x); sum +=
- 16. Advanced for Loops int i=100,sum=0; while(i != 0) sum += i- -; Console.WriteLine(“sum is {0}”, sum);
- 17. In contrast to the for statement, the while statement allows us to loop through a statement
- 18. Like for loops while loops may also be nested. Example A program to guess a letter
- 19. Do While Statement In both the for and while statements the test condition is evaluated before
- 20. Break Statement When a break statement is encountered in a for, while, do while or switch
- 21. Continue Statement The continue statement terminates the current iteration of a for, while or do while
- 23. Скачать презентацию