Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
•Switch Case and•Looping Statement             By: Margareth Lota                 http://eglobiotraining.com/
http://eglobiotraining.com/
- A switch, case, select or inspect statement is a type of selection control     mechanism that exists in most imperative ...
Switch case statements are a substitutefor long if statements that compare a variable  to several "integral" values ("inte...
Switch case statements are a substitutefor long if statements that compare a variable  to several "integral" values ("inte...
1. The If – else Statement  -The if statement allows the programmer to make   decisions within a program.   - The general ...
If statement (two alternatives) Form:  If (condition)        Note: if condition evaluates to true, then statement is      ...
   If we know how to write a C expression that is equivalent    of a question such as “Is resting the value of expression...
We first define the word “programming”, it is a   computer language programmers use to develop  applications, scripts, or ...
As an individual, I have learned thatprogramming is a very broad because it composesmany scripts, applications and can be ...
The distinction between data and procedures    is not that clear cut. In many programminglanguages, procedures can be pass...
At first, programming is confusing becauseyou have so much to understand about codes thatwill enable to run a program. Pro...
You have to consider languages to run or write yourown program, most demanded language in programming isthe DEV C++ (a ful...
   1. Open Dev C++   2. Click File and choose New   3. Post your Statements   4. after you post your statement   5. S...
http://eglobiotraining.com/
Link:   http://gd.tuwien.ac.at/languages/c/programming-        bbrown/c_028.htmThe above program uses a switch statement t...
When it compiles and run, this will be it look .The C expression that was type it on Dev C++The words are “enter in two nu...
Link:   http://www.morrowland.com/apron/tutorials/cpp/cp        p_switch_case/index.php                                 Ex...
After I compile it and run it, the statement is now like this. As youCan see after you answer the 1st question the next qu...
Link:http://www.morrowland.com/apron/tutorials/cpp/cpp_if_else/index.php        Function and target of       Programming l...
When the statement was done this will it be look like.I got this from the URL . The URL was posted on the previous        ...
http://msdn.microsoft.com/en-us/library/66k51h7a(v=vs.80).aspxDid You Know?The first programminglanguages predate themoder...
Did You Know ?All programming languages have some primitive building blocks for thedescription of data and the processes o...
Link:   http://www.cfanatic.com/topic4267/                                       http://eglobiotraining.com/
http://eglobiotraining.com/
http://eglobiotraining.com/
Looping                          Statements  - Loops execute a block of code a specified number of    times, or while a s...
Loops are used to repeat a block of code.Being able to have your program repeatedlyexecute a block of code is one of the m...
            (They may be executing a small    number of tasks, but in principle, to produce a    list of messages only re...
Loops are used to repeat a block of code.Being able to have your program repeatedlyexecute a block of code is one of the m...
While structure is another type of loop statements,where the condition is checked at first, the iterationwill not stop eve...
            Notice that the condition is tested at    the end of the block instead of the    beginning, so the block will...
   I noticed that sometimes if the program does not run, it    is because some braces are not included and I    accidenta...
   So much codes that should be entered that even the    spaces are needed programming is very specific that    whatever ...
   Because of so many experiences I had before this program    run, I found programming is also interesting for the more ...
Break is a keyword that breaks out of thecode block, usually surrounded bybraces, which it is in. In this case, breakpreve...
    Do while statement is same as the while     statement , the only difference is that it     evaluates the expression a...
   The for loop is used when you know in advance how many    times the script should run.   Be for statement takes three...
Form:        for {initialization; condition:       increment )            {             code to be executed            }ht...
   For Each structure is a loop structure used for    arraysForm:foreach(array as value){  code to be executed}Foreach (a...
   Break ends the execution of the for, for    each, while, do-while or switch statement.Form:* Break ( optional numeric ...
   “Continue” is used to skip the current loop iteration    and continue with the next iteration of the loop. But    “Bre...
   When I learned that programming is very    sensitive and at the same time very detailed when    it comes to entering c...
http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php                                              The for ...
http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php                                            http://egl...
http://www.morrowland.com/apron/tutorials/cpp/cpp_do_while_loop/index.php                                           Do whi...
http://eglobiotraining.com/
http://www.exforsys.com/tutorials/c-plus-plus/looping-in-c.html                                                           ...
http://eglobiotraining.com/
http://cprogramminglanguage.net/c-break-continue-statements.aspx                                                       Bre...
http://eglobiotraining.com/
http://www.w3schools.com/php/php_looping_for.asp                       Foreach loop                               http://e...
http://eglobiotraining.com/
Maggybells   http://eglobiotraining.com/
Upcoming SlideShare
Loading in …5
×

Margareth lota

589 views

Published on

Programming

  • Be the first to comment

  • Be the first to like this

Margareth lota

  1. 1. •Switch Case and•Looping Statement By: Margareth Lota http://eglobiotraining.com/
  2. 2. http://eglobiotraining.com/
  3. 3. - A switch, case, select or inspect statement is a type of selection control mechanism that exists in most imperative programming languages such as Pascal, Ada, C/C++, C#, Java, and so on. It is also included in several other types of languages. Its purpose is to allow the value of a variable or expression to control the flow of program execution via a multiway branch (or "goto", one of several labels).The Main Reason using switch case : - To improve clarity, by reducing otherwise repetitive coding, and (if the heuristics permit) also offering the potential for faster execution through easier compiler optimization in many cases. http://eglobiotraining.com/
  4. 4. Switch case statements are a substitutefor long if statements that compare a variable to several "integral" values ("integral" valuesare simply values that can be expressed as an integer, such as the value of a char). http://eglobiotraining.com/
  5. 5. Switch case statements are a substitutefor long if statements that compare a variable to several "integral" values ("integral" valuesare simply values that can be expressed as an integer, such as the value of a char). http://eglobiotraining.com/
  6. 6. 1. The If – else Statement -The if statement allows the programmer to make decisions within a program. - The general format of an if statement is: If (expression) statement -Where expression represents a relational, equality, or logical expression ( conditional expression) . http://eglobiotraining.com/
  7. 7. If statement (two alternatives) Form: If (condition) Note: if condition evaluates to true, then statement is statement; executed and statement is skipped; otherwise, statement is else skipped and statement is executed statement;If statement (One-Alternatives) Form: If (condition) Note: if condition evaluates to true, then statement is statement; executed and statement is skippedFormat of the if statement- All if statement examples in this text indent statements. The word elseIs typed without indention on a separate line. The format of the if statementmakes its meaning apparent and is used solely to improve program readability;The format makes no difference to the computer http://eglobiotraining.com/
  8. 8.  If we know how to write a C expression that is equivalent of a question such as “Is resting the value of expression to select a course of action. In C, the statement is the primary selection control structure Me: it’s hard to write c expression. So, I just copy and paste it into internet. A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely. http://eglobiotraining.com/
  9. 9. We first define the word “programming”, it is a computer language programmers use to develop applications, scripts, or other set of instructions for a computer to execute. programming is instructing a computer to do something for you with the help of a programming language. The role of a programming language can be described in two ways:  Technical: It is a means for instructing a Computer to perform Tasks Conceptual: It is a framework within which we organize our ideas about things and processes. http://eglobiotraining.com/
  10. 10. As an individual, I have learned thatprogramming is a very broad because it composesmany scripts, applications and can be used to run aprogram that has been part of the programminglanguage. A programming language should both providemeans to describe primitive data and procedures andmeans to combine and abstract those into morecomplex ones. http://eglobiotraining.com/
  11. 11. The distinction between data and procedures is not that clear cut. In many programminglanguages, procedures can be passed as data (to be applied to ``real data) and sometimes processed like ``ordinary data. Conversely``ordinary data can be turned into procedures by an evaluation mechanism. http://eglobiotraining.com/
  12. 12. At first, programming is confusing becauseyou have so much to understand about codes thatwill enable to run a program. Programming hasapplications and program development, the bestexample for this is the Internet bowser… Programming is a creative process done byprogrammers to instruct a computer on how to doa task. Programming languages let you use themin different ways, e.g adding numbers, etc… orstoring data on disk for later retrieval. http://eglobiotraining.com/
  13. 13. You have to consider languages to run or write yourown program, most demanded language in programming isthe DEV C++ (a full-featured Integrated DevelopmentEnvironment (IDE)). C++ is one of the most used programminglanguages in the world. Also known as "C with Classes".New to programming or thinking about it? It might surpriseyou to know that there are many programmers whoprogram just for fun and it can lead to a job. http://eglobiotraining.com/
  14. 14.  1. Open Dev C++ 2. Click File and choose New 3. Post your Statements 4. after you post your statement 5. Save it .choose file and save or 6. click f9 or you can see it shaped like a square http://eglobiotraining.com/
  15. 15. http://eglobiotraining.com/
  16. 16. Link: http://gd.tuwien.ac.at/languages/c/programming- bbrown/c_028.htmThe above program uses a switch statement to validate and select uponthe users input choice, simulating a simple menu of choices. http://eglobiotraining.com/
  17. 17. When it compiles and run, this will be it look .The C expression that was type it on Dev C++The words are “enter in two number  24” http://eglobiotraining.com/
  18. 18. Link: http://www.morrowland.com/apron/tutorials/cpp/cp p_switch_case/index.php Example of Switch Case Statement , you Will see the statement on the link that you see in this slide. http://eglobiotraining.com/
  19. 19. After I compile it and run it, the statement is now like this. As youCan see after you answer the 1st question the next question appearAnd after you finish all the question the box will disappear. It means finish. http://eglobiotraining.com/
  20. 20. Link:http://www.morrowland.com/apron/tutorials/cpp/cpp_if_else/index.php Function and target of Programming language : A computer programming language is a language. used to write computer programs, which involve a computer performing some kind of computation or algorithm and possibly control external devices such as printers , disk drives , robots, and so on. http://eglobiotraining.com/
  21. 21. When the statement was done this will it be look like.I got this from the URL . The URL was posted on the previous slide http://eglobiotraining.com/
  22. 22. http://msdn.microsoft.com/en-us/library/66k51h7a(v=vs.80).aspxDid You Know?The first programminglanguages predate themodern computer. The19th century saw theinvention of"programmable" looms and player piano scrolls, bothof which implementedexamples ofdomain-specific languages. http://eglobiotraining.com/
  23. 23. Did You Know ?All programming languages have some primitive building blocks for thedescription of data and the processes or transformations applied tothem(like the addition of two numbers or the selection of an item from acollection). These primitives are defined by syntactic and semantic ruleswhich describe their structure and meaning respectively. http://eglobiotraining.com/
  24. 24. Link: http://www.cfanatic.com/topic4267/ http://eglobiotraining.com/
  25. 25. http://eglobiotraining.com/
  26. 26. http://eglobiotraining.com/
  27. 27. Looping Statements - Loops execute a block of code a specified number of times, or while a specified condition is true. - in PHP, the following looping statements are used: *The while Loop * The Do… While Loop * The For Loop *The Foreach Loop *Break and continue statementhttp://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  28. 28. Loops are used to repeat a block of code.Being able to have your program repeatedlyexecute a block of code is one of the mostbasic but useful tasks in programming -- manyprograms or websites that produce extremelycomplex output (such as a message board) arereally only executing a single task many times. http://eglobiotraining.com/
  29. 29.  (They may be executing a small number of tasks, but in principle, to produce a list of messages only requires repeating the operation of reading in some data and displaying it.) Now, think about what this means: a loop lets you write a very simple statement to produce a significantly greater result simply by repetition. http://eglobiotraining.com/
  30. 30. Loops are used to repeat a block of code.Being able to have your program repeatedlyexecute a block of code is one of the mostbasic but useful tasks in programming -- manyprograms or websites that produce extremelycomplex output (such as a message board) arereally only executing a single task many times. http://eglobiotraining.com/
  31. 31. While structure is another type of loop statements,where the condition is checked at first, the iterationwill not stop even if the value changes while executingstatements. Form: While(condition) { code to be executed; } http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  32. 32.  Notice that the condition is tested at the end of the block instead of the beginning, so the block will be executed at least once. If the condition is true, we jump back to the beginning of the block and execute it again. A do..while loop is basically a reversed while loop. A while loop says "Loop while the condition is true, and execute this block of code", a do..while loop says "Execute this block of code, and loop while the condition is true". http://eglobiotraining.com/
  33. 33.  I noticed that sometimes if the program does not run, it is because some braces are not included and I accidentally put braces on the same line and it causes the program not to read its contents. Programming is sensitive, when there is missing variable or braces or some words it does not run. http://eglobiotraining.com/
  34. 34.  So much codes that should be entered that even the spaces are needed programming is very specific that whatever you have entered in to it you should specify because when the statement is false it wouldn’t let you run the program, I have experienced it before I arrived at this result. http://eglobiotraining.com/
  35. 35.  Because of so many experiences I had before this program run, I found programming is also interesting for the more you are practicing to make a program run, the more questions that came up in my mind and try something that will fit to this or entering new codes to make matrix etc… that I know is possible. http://eglobiotraining.com/
  36. 36. Break is a keyword that breaks out of thecode block, usually surrounded bybraces, which it is in. In this case, breakprevents the program from falling through andexecuting the code in all the other casestatements. http://eglobiotraining.com/
  37. 37.  Do while statement is same as the while statement , the only difference is that it evaluates the expression at the end. Form: do { code to be executed; } while (condition): http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  38. 38.  The for loop is used when you know in advance how many times the script should run. Be for statement takes three expressions inside its parentheses seperated by semi-colons. When the for loop executes, the following occurs: The initializing expression is executed. This expression usually initializes oneor more loop counter, but the syntax allow expression any degree of complexity. The condition expression is evaluated. Of the value of condition is true, the loop statements execute. If the value of condition is false, the for loop terminates. http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  39. 39. Form: for {initialization; condition: increment ) { code to be executed }http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  40. 40.  For Each structure is a loop structure used for arraysForm:foreach(array as value){ code to be executed}Foreach (array as key => value){ code to be executed} http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  41. 41.  Break ends the execution of the for, for each, while, do-while or switch statement.Form:* Break ( optional numeric argument) http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  42. 42.  “Continue” is used to skip the current loop iteration and continue with the next iteration of the loop. But “Break” is to exit from the whole loop.Form:* Break ( optional numeric argument) http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  43. 43.  When I learned that programming is very sensitive and at the same time very detailed when it comes to entering codes, I make sure that it is clear means that I put everything important codes in it so that the program would run. http://eglobiotraining.com/
  44. 44. http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php The for loop http://eglobiotraining.com/
  45. 45. http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php http://eglobiotraining.com/
  46. 46. http://www.morrowland.com/apron/tutorials/cpp/cpp_do_while_loop/index.php Do while loop http://eglobiotraining.com/
  47. 47. http://eglobiotraining.com/
  48. 48. http://www.exforsys.com/tutorials/c-plus-plus/looping-in-c.html While loop http://eglobiotraining.com/
  49. 49. http://eglobiotraining.com/
  50. 50. http://cprogramminglanguage.net/c-break-continue-statements.aspx Break and continue http://eglobiotraining.com/
  51. 51. http://eglobiotraining.com/
  52. 52. http://www.w3schools.com/php/php_looping_for.asp Foreach loop http://eglobiotraining.com/
  53. 53. http://eglobiotraining.com/
  54. 54. Maggybells http://eglobiotraining.com/

×