Programming in C#

Topics: For loop, Statement, Switch statement Pages: 4 (606 words) Published: July 24, 2013
Short-circuiting logical operators
&& and ||
OR (||) expressions – if the first evaluates as true, no need to evaluate the second operand AND (&&) expressions – if the first evaluates as false, no need to evaluate second operand C# also includes the & and | operators

logical does not perform short-circuit evaluation

NESTED-IF ELSE STATEMENT
* Acceptable to write an if within an if
* When block is completed, all remaining conditional expressions are skipped or bypassed * Syntax for nested if…else follows that of two-way
* Difference: With a nested if…else, the statement may be another if statement * No restrictions on the depth of nesting
Limitation comes in the form of whether you and others can read and follow your code SWITCH STATEMENT
* Multiple selection structure
* Also called case statement
* Works for tests of equality only
* Single variable or expression tested
* Must evaluate to an integral or string value
* Requires the break for any case
* No fall-through available
PRECEDENCE OF THE OPERATORS
* Associativity
* Left-associative
* All binary operators except assignment operators
* Right-associative
* Assignment operators and the conditional operator ?
* Operations are performed from right to left
* Order changed through use of parentheses
LOOPING STATEMENTS
Types of loops
* while
* Counter-controlled
* Sentinel-controlled
* State-controlled
* for
* foreach
* do…while

1. WHILE STATEMENT
* Simplest and most frequently used loop
* Syntax : while (conditional expression)
statement(s);
* Expression – sometimes called loop condition
* Returns a Boolean result of true or false
* No semicolon after the conditional expression
* Null body→ empty bodied loop→ infinite loop
* Enclose multiple statements for body in { }

a. COUNTER-CONTROLLED LOOP
* Loop...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Essay about Programming C++
  • Programming in C Essay
  • programming C Essay
  • Introduction to the C# Programming Language Essay
  • structered programming Essay
  • Essay on C Programming for Embedded Microcontroller Systems
  • C++ Programming Language Essay
  • Applications in C# Programming Language Essay

Become a StudyMode Member

Sign Up - It's Free