Presentation is loading. Please wait.

Presentation is loading. Please wait.

C# and the .NET Framework

Similar presentations


Presentation on theme: "C# and the .NET Framework"— Presentation transcript:

1 C# and the .NET Framework
Control Structures

2 Java relational and equality operators
Operator Symbol Meaning Example < less than 31 < 25 is false <= less than or equal to 464 <= 7213 is true > greater than -98 > -12 >= greater than or equal to 9 >= 99 == equal to 9 == != not equal to 292 != 377 Java relational and equality operators

3 The if Statement Type bool Two values, true and false if (condition)
if_true_statement The condition is a bool expression. If it is true then the if_true_statement will be executed if (x >2) y = x + 17;

4 The sequence control flow
Entry int item1 = 25; int item2 = 12; Item2 = item1+15; Exit The sequence control flow

5 Control flow for the if statement
true condition if_true_statement false Control flow for the if statement

6 The if-else statement Choose between two alternatives
if (condition) if ( x <= 20) if_true_statement x += 5; else else if_false_statement x+=2;

7 Flow chart for the if-else statement
True False Condition if_true_statement if_false_statement Flow chart for the if-else statement

8 Blocks Group a sequence of statements inside braces { x = 5; y = -8;
z = x*y; } May use a block in an if or if-else statement

9 Scientific Notation Small or large numbers are hard to read
Use exponents instead 3.937E-8 instead of 5.88E12 instead of 5,880,000,000,000 E or e E12 or E+12

10 Type double Provides about 16 decimal places
double length = E5; // exponent double height 1.83; // fixed +,-,*,/ operators

11 Formatted Output {0:E} Scientific default (three decimal places)
{0:F2} Fixed-point, two decimal places {O:G} General, default (same as {0})

12 while statement Provides repetition while (condition)
while_true_statement while (x < 10) x += 2; If x = 5, then x becomes 7, 9 before loop stops x -= 4; //does not terminate if x starts at 5

13 while_true_statement
False True Condition while_true_statement Flow chart for the while loop

14 Pseudocode for the sum of test scores problem
Read the quantity of scores; while(count < quantity) { Read the next score; Add the score to the total so far; Increment the count of scores; } Display the quantity and the total; Pseudocode for the sum of test scores problem


Download ppt "C# and the .NET Framework"

Similar presentations


Ads by Google