fundamentals of programming finals.ajang
DESCRIPTION
TRANSCRIPT
![Page 1: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/1.jpg)
•Switch Case and •Looping Statement
![Page 2: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/2.jpg)
http://en.wikipedia.org/wiki/Switch_statement
http://eglobiotraining.com/
http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_028.htm
http://www.morrowland.com/apron/tutorials/cpp/cpp_switch_case/index.php
![Page 4: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/4.jpg)
- 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.
![Page 5: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/5.jpg)
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, orlogical expression ( conditional expression) .
![Page 6: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/6.jpg)
http://eglobiotraining.com/
If statement (One-Alternatives)
If (condition) statement;
Form:
Note: if condition evaluates to true, then statement is executed and statement is skipped
If statement (two alternatives)
Form:If (condition) statement;else statement;
Note: if condition evaluates to true, then statement is executed and statement is skipped; otherwise, statement is skipped and statement is executed
Format 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 statement makes its meaning apparent and is used solely to improve program readability; The format makes no difference to the computer
![Page 7: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/7.jpg)
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/
![Page 8: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/8.jpg)
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/
![Page 10: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/10.jpg)
http://eglobiotraining.com/
http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_028.htm
Link:
The above program uses a switch statement to validate and select upon the users input choice, simulating a simple menu of choices.
![Page 11: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/11.jpg)
http://eglobiotraining.com/
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”
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”
![Page 12: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/12.jpg)
http://eglobiotraining.com/
http://www.morrowland.com/apron/tutorials/cpp/cpp_switch_case/index.php
Link:
Example of Switch Case Statement , you Will see the statement on the link that you see in this slide.
![Page 13: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/13.jpg)
http://eglobiotraining.com/
After I compile it and run it, the statement is now like this. As you Can see after you answer the 1st question the next question appear And after you finish all the question the box will disappear. It means finish.
![Page 14: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/14.jpg)
http://eglobiotraining.com/
http://www.morrowland.com/apron/tutorials/cpp/cpp_if_else/index.php
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.
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.
![Page 15: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/15.jpg)
http://eglobiotraining.com/
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
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
![Page 16: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/16.jpg)
http://eglobiotraining.com/
http://msdn.microsoft.com/en-us/library/66k51h7a(v=vs.80).aspx
![Page 18: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/18.jpg)
http://eglobiotraining.com/http://www.cfanatic.com/topic4267/Link:
![Page 21: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/21.jpg)
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
http://eglobiotraining.com/http://www.slideshare.net/ilakkiya/looping-statement
![Page 22: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/22.jpg)
http://eglobiotraining.com/
While structure is another type of loop statements, where the condition is checked at first, the iteration will not stop even if the value changes while executing statements.
Form: While(condition){ code to be executed;}
http://www.slideshare.net/ilakkiya/looping-statement
![Page 23: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/23.jpg)
Do while statement is same as the while statement , the only difference is that it evaluates the expression at the end.
http://eglobiotraining.com/
Form: do { code to be executed; } while (condition):
http://www.slideshare.net/ilakkiya/looping-statement
![Page 24: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/24.jpg)
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/
![Page 25: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/25.jpg)
http://eglobiotraining.com/
Form:
for {initialization; condition: increment ) { code to be executed }
http://www.slideshare.net/ilakkiya/looping-statement
![Page 26: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/26.jpg)
For Each structure is a loop structure used for arrays
Form:foreach(array as value){ code to be executed}
Foreach (array as key => value){ code to be executed} http://eglobiotraining.com/
http://www.slideshare.net/ilakkiya/looping-statement
![Page 27: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/27.jpg)
Break ends the execution of the for, for each, while, do-while or switch statement.
http://eglobiotraining.com/
Form:* Break ( optional numeric argument)
http://www.slideshare.net/ilakkiya/looping-statement
![Page 28: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/28.jpg)
“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.
http://eglobiotraining.com/
Form:* Break ( optional numeric argument)
http://www.slideshare.net/ilakkiya/looping-statement
![Page 29: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/29.jpg)
http://eglobiotraining.com/
http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php
The for loop
![Page 30: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/30.jpg)
http://eglobiotraining.com/
http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php
![Page 31: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/31.jpg)
http://www.morrowland.com/apron/tutorials/cpp/cpp_do_while_loop/index.php
Do while loop
http://eglobiotraining.com/
![Page 32: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/32.jpg)
http://eglobiotraining.com/
![Page 33: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/33.jpg)
http://eglobiotraining.com/
http://www.exforsys.com/tutorials/c-plus-plus/looping-in-c.html
While loop
![Page 34: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/34.jpg)
http://eglobiotraining.com/
![Page 35: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/35.jpg)
http://eglobiotraining.com/
http://cprogramminglanguage.net/c-break-continue-statements.aspx
Break and continue
![Page 36: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/36.jpg)
http://eglobiotraining.com/
![Page 37: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/37.jpg)
http://eglobiotraining.com/
http://www.w3schools.com/php/php_looping_for.asp
Foreach loop
![Page 38: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/38.jpg)
![Page 39: Fundamentals of programming finals.ajang](https://reader033.vdocuments.mx/reader033/viewer/2022061305/549d3148ac7959d32a8b496a/html5/thumbnails/39.jpg)
Presented By:Marquez, Jaricka Angelyd B.BM10203