The C# language fundamentals ( II ) Po Feng, Tsai.

Slides:



Advertisements
Similar presentations
Comp Sci Control structures 1 Ch. 5 Control Structures.
Advertisements

Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
1 Gentle Introduction to Programming Tirgul 2: Scala “hands on” in the lab.
Inline Function. 2 Expanded in a line when it is invoked Ie compiler replace the function call with function code To make a function inline the function.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
Algorithms and Computing Lecture 3 Control Statements By Dr. M. Tahir Khaleeq.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
COMPUTER PROGRAMMING. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may repeat code.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
1 Session 3: Flow Control & Functions iNET Academy Open Source Web Programming.
Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation.
The scope of local variables. Murphy's Law The famous Murphy's Law says: Anything that can possibly go wrong, does. (Wikipedia page on Murphy's Law:
The C# language fundamentals ( I ) P.F. Tsai. Hello World Project Please follow the instructions mentioned in the previous class to build a hello world.
Chapter 2: Java Fundamentals
Controlling Execution Dong Shao, Nanjing Unviersity.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Week 3 - Wednesday.  What did we talk about last time?  Other C features  sizeof, const  ASCII table  printf() format strings  Bitwise operations.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Select (drop-down list) Inputs. Insert/Form/List Menu.
CPS120 Introduction to Computer Science Iteration (Looping)
1 Chapter 3: Loops and Logic. 2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If.
CS 161 Introduction to Programming and Problem Solving Chapter 18 Control Flow Through C++ Program Herbert G. Mayer, PSU Status 10/8/2014 Initial content.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Control Flow Statements
CRE Programming Club - Class 4 Robert Eckstein and Robert Heard.
CISC105 – General Computer Science Class 4 – 06/14/2006.
Engineering Computing I Chapter 3 Control Flow. Chapter 3 - Control Flow The control-flow of a language specify the order in which computations are performed.
Week 3 - Friday.  What did we talk about last time?  Preprocessor directives  Other C features  sizeof, const  ASCII table  printf() format strings.
Program Control: Selection Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
Learning Javascript From Mr Saem
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CONTENTS Loop Statements Parts of a loop Types of Loops Nested Loops
Program Control: Selection Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
PH2150 Scientific Computing Skills Control Structures in Python In general, statements are executed sequentially, top to bottom. There are many instances.
Enum. enum – a new type 2 enum is a set of constant int values, that defines a type: enum Season { WINTER,// = 0 by default SPRING,// = WINTER + 1 SUMMER,//
C++ First Steps.
CSE 220 – C Programming Loops.
Fundamentals of PL/SQL part 2 (Basics)
Unit-1 Introduction to Java
Programming Fundamentals
Flow of Control.
Flow of Control.
Debuggers.
Conditional Statements
Chapter 6 Decision Making and Looping
Professor Jodi Neely-Ritz CGS3460
Govt. Polytechnic,Dhangar
Flow of Control.
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Exceptions.
Lab5 PROGRAMMING 1 Loop chapter4.
Homework Any Questions?.
Control Structures Part 3
Problems Debugging is fine and dandy, but remember we divided problems into compile-time problems and runtime problems? Debugging only copes with the former.
Program Flow.
Selection Statements Chapter 3.
MIPS assembly.
CSC215 Lecture Control Flow.
Enum.
Corresponds with Chapter 5
Introduction to Python
Presentation transcript:

The C# language fundamentals ( II ) Po Feng, Tsai

Switch statements An alternative to nested ifs Similar to Matlab

The goto and break keywords The switch statement Fall through Goto Move to another address with specified label Create a label and the goto the label Break Jump out of the switch statement Averting from using goto is strongly suggested Complicating your codes

Fall through you cannot fall through to the next case if the case statement is not empty

Loops The while loop Example

Exercise 7 Please try to use the while loop to print the following message * ** *** **** ***** Debugger

Loops The do … while loop Example

Loops The for loop Example remainder

Exercise 8 Please try to use the for loop to print the following message * ** *** **** *****

Continue & Break The continue statement causes the loop to return to the top and continue executing The break statement causes the loop to stop and jump out of executing block Example

Alarm system (3-15)

Exercise 9 Please implement a multiplication table (3x9) with any of the loops mentioned above

The ternary operator Usage Example

Preprocessor Directives Before your code is compiled, another program called the preprocessor runs and prepares your program for the compiler begin with the pound sign (#) Usually for debugging purpose

Example 1

Example 2

#region Used to mark off areas of code and collapse them Paired with #endregion Additional information can be attached right after the label

Click here