1 / 9

Introduction to Algorithm

Introduction to Algorithm. Normal situation – a morning. Wake Up Brush Teeth Take Shower Get Dressed Eat Breakfast Go to Work. BUT what if we change order?. Wake Up Brush Teeth Eat Breakfast Get Dressed Take Shower Go to Work.

calum
Télécharger la présentation

Introduction to Algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Algorithm

  2. Normal situation – a morning Wake Up BrushTeethTakeShowerGetDressedEatBreakfast Go to Work

  3. BUT what if we change order? Wake Up BrushTeethEatBreakfastGetDressedTakeShower Go to Work

  4. Programs need control • We have Three control structures • SEQUENCE structure (normal if we do not do anything i.e. line by line) • SELECTION structure (braches e.g. IF-statements) • REPETITION structures (loops e.g. WHILE-statements)

  5. SEQUENCE structures

  6. SELECTION structures IF – Statement – Logic (semantic) IF – Statement – code (syntax) If (grade > 60) Console.WriteLine(”Passed”);

  7. SELECTION structures 2 IF – ELSE - Statement – Logic (semantic) IF – ELSE Statement – code (syntax) If (grade > 60) Console.WriteLine(”Passed”); else Console.WriteLine(”Failed”);

  8. Nested IF statements

  9. Nested IF statements 2 - another formatting

More Related