Fundamentals of programming final santos


Published on

Published in: Education
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Fundamentals of programming final santos

  1. 1. •Switch Case and•Looping Statement By:Abigail C.Santos BM 10203
  2. 2. •Programming•Switch Case The If – else Statement If statement (two alternatives) If statement (One-Alternatives) How to save and run your statement Five Programs that is related on switch case program Output•Looping Statement The while Loop The Do… While Loop The For Loop The Foreach Loop Break and continue statement Output
  3. 3.
  4. 4. ProgrammingWe first define the word “programming”, it is a computer languageprogrammers use to develop applications, scripts, or other set ofinstructions for a computer to execute. programming is instructing a computer to do something foryou with the help of a programming language. The role of aprogramming language can be described in two ways:Technical: It is a means for instructing a Computer to perform TasksConceptual: It is a framework within which we organize our ideasabout things and processes.
  5. 5. As an individual, I have learned that programming is avery broad because it composes many scripts,applications and can be used to run a program thathas been part of the programming language. A programming language should both providemeans to describe primitive data and procedures andmeans to combine and abstract those into morecomplex ones.
  6. 6.  The distinction between data and procedures is not that clear cut. In many programming languages, 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.
  7. 7.  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.
  8. 8. At first, programming is confusing because you have so much tounderstand about codes that will enable to run a program.Programming has applications and program development, the bestexample for this is the Internet browser… Programming is a creative process done by programmers toinstruct a computer on how to do a task. Programming languages letyou use them in different ways, e.g adding numbers, etc… or storingdata on disk for later retrieval.
  9. 9. You have to consider languages to run orwrite your own program, most demanded languagein programming is the DEV C++ (a full-featuredIntegrated Development Environment (IDE)). C++ is one of the most used programminglanguages in the world. Also known as "C withClasses".New to programming or thinking about it? It mightsurprise you to know that there are manyprogrammers who program just for fun and it canlead to a job.
  10. 10. - A switch, case, select or inspect statement is a type of selection controlmechanism that exists in most imperative programming languages suchas Pascal, Ada, C/C++, C#, Java, and so on. It is also included in severalother types of languages. Its purpose is to allow the value of a variable orexpression to control the flow of program execution via a multiwaybranch (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.
  11. 11. 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) .
  12. 12. 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
  13. 13.  There may be a situation when you need to execute a block of code several number of times. In general statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times and following is the general from of a loop statement in most of the programming languages:
  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
  15. 15.
  16. 16. Link: bbrown/c_028.htmThe above program uses a switch statement to validate and select uponthe users input choice, simulating a simple menu of choices.
  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”
  18. 18. Link: p/cpp_switch_case/index.php Example of Switch Case Statement , you Will see the statement on the link that you see in this slide.
  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 meansfinish.
  20. 20. Link: 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.
  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
  22. 22. You Know?The first programminglanguages predate themodern computer. The19th century saw theinvention of"programmable" looms and player piano scrolls, bothof which implementedexamples of domain-specific languages.
  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.
  24. 24. Link:
  25. 25.
  26. 26.
  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 statement
  28. 28. 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; }
  29. 29.  Dowhile 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):
  30. 30.  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 separated by semi-colons. When the for loop executes, the following occurs: The initializing expression is executed. This expression usually initializes one or 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.
  31. 31. Form: for {initialization; condition: increment ) { code to be executed }
  32. 32.  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}
  33. 33.  Breakends the execution of the for, for each, while, do-while or switch statement.Form:* Break ( optional numeric argument)
  34. 34.  “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)
  35. 35. The for loop
  36. 36.
  37. 37. Do while loop
  38. 38.
  39. 39. loop
  40. 40.
  41. 41. Break and continue
  42. 42.
  43. 43. For each loop
  44. 44.
  45. 45.  Slideshare account :abie santos
  46. 46. In Partial fulfillment of requirements in Fundamental of ProgrammingSubmitted to : Prof. Erwin Globio By: Abigail C. Santos