SlideShare ist ein Scribd-Unternehmen logo
1 von 39
•Switch Case and
•Looping Statement
http://en.wikipedia.org/wiki/Switch_statement

  http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_028.htm



 http://www.morrowland.com/apron/tutorials/cpp/cpp_switch_case/index.php




                                             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 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.
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) .
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 skipped

Format of the if statement
    - All if statement examples in this text indent statements. The word else
    Is 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



                                                        http://eglobiotraining.com/
   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/
   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/
http://eglobiotraining.com/
Link:   http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_028.htm




The above program uses a switch statement to validate and select upon the
users input choice, simulating a simple menu of choices.

                                              http://eglobiotraining.com/
When it compiles and run, this will be it look .
The C expression that was type it on be it C++ .
 When it compiles and run, this will Dev look
The words are “enter in two number  24”C++
 The C expression that was type it on Dev
 The words are “enter in two number  24”



                                          http://eglobiotraining.com/
Link:   http://www.morrowland.com/apron/tutorials/cpp/cpp_switc




                                  Example of Switch
                                  Case Statement , you
                                  Will see the statement
                                  on the link that you see
                                  in this slide.




                             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.



                                                      http://eglobiotraining.com/
Link:
http://www.morrowland.com/apron/tutorials/cpp/cpp_if_else/index.php




  Function and target of Programming
   language : and target of Programming
     Function A computer programming
      language : A computer programming
        language is a language. used to
      write computer programs,used to
          language is a language. which
  involve a computer performingwhich
         write computer programs, some
  kind of computation or algorithm some
     involve a computer performing and
     kind of computation or algorithm and
  possibly control external devices such
     possibly control external devices such
    as printers , disk drives , robots, and
       as printers , diskon.
                      so drives , robots, and
                        so on.




                                                  http://eglobiotraining.com/
When the statement was done this will it be look like.
I got thisWhen the URL . The URL was posted onit be previous slide
           from the statement was done this will the look like.
  I got this from the URL . The URL was posted on the previous slide



                                          http://eglobiotraining.com/
http://msdn.microsoft.com/en-us/library/66k51h7a(v=vs.80).aspx




                                         http://eglobiotraining.com/
http://eglobiotraining.com/
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 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://www.slideshare.net/ilakkiya/looping-statement
                                                       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
                                       http://eglobiotraining.com/
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/
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/
Form:

        for {initialization; condition:
       increment )
          {
           code to be executed
          }




http://www.slideshare.net/ilakkiya/looping-statement


                                            http://eglobiotraining.com/
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://www.slideshare.net/ilakkiya/looping-statement
}
                                                 http://eglobiotraining.com/
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/
“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/
http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php




                                                  The for loop




                                            http://eglobiotraining.com/
http://www.morrowland.com/apron/tutorials/cpp/cpp_for_loop/index.php




                                              http://eglobiotraining.com/
http://www.morrowland.com/apron/tutorials/cpp/cpp_do_while_loop/index.php



                                             Do while loop




                                            http://eglobiotraining.com/
http://eglobiotraining.com/
http://www.exforsys.com/tutorials/c-plus-plus/looping-in-c.html




                                                                    While loop




                                      http://eglobiotraining.com/
http://eglobiotraining.com/
http://cprogramminglanguage.net/c-break-continue-statements.aspx




                                                           Break and continue




                                         http://eglobiotraining.com/
http://eglobiotraining.com/
http://www.w3schools.com/php/php_looping_for.asp




                         Foreach loop




                                http://eglobiotraining.com/
Presented By:
Marquez, Jaricka Angelyd B.
BM10203

Weitere ähnliche Inhalte

Was ist angesagt?

Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming LanguageMahantesh Devoor
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareGagan Deep
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements loopingMomenMostafa
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loopsbsdeol28
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programmingCHANDAN KUMAR
 
Looping Statement And Flow Chart
 Looping Statement And Flow Chart Looping Statement And Flow Chart
Looping Statement And Flow ChartRahul Sahu
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For LoopSukrit Gupta
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 
Loops in c language
Loops in c languageLoops in c language
Loops in c languagetanmaymodi4
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Php Operators N Controllers
Php Operators N ControllersPhp Operators N Controllers
Php Operators N Controllersmussawir20
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCRberiver
 

Was ist angesagt? (20)

Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
Loops in c
Loops in cLoops in c
Loops in c
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements looping
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Loops in c
Loops in cLoops in c
Loops in c
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
Looping Statement And Flow Chart
 Looping Statement And Flow Chart Looping Statement And Flow Chart
Looping Statement And Flow Chart
 
Looping
LoopingLooping
Looping
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Iteration
IterationIteration
Iteration
 
Control statements
Control statementsControl statements
Control statements
 
Different loops in C
Different loops in CDifferent loops in C
Different loops in C
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Statements and Conditions in PHP
Statements and Conditions in PHPStatements and Conditions in PHP
Statements and Conditions in PHP
 
Php Operators N Controllers
Php Operators N ControllersPhp Operators N Controllers
Php Operators N Controllers
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCR
 

Andere mochten auch

Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3Warawut
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentEduardo Bergavera
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C ProgrammingHimanshu Negi
 
Control structure C++
Control structure C++Control structure C++
Control structure C++Anil Kumar
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.Haard Shah
 

Andere mochten auch (7)

Object-Oriented Programming 3
Object-Oriented Programming 3Object-Oriented Programming 3
Object-Oriented Programming 3
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software Development
 
C++ loop
C++ loop C++ loop
C++ loop
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C Programming
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 

Ähnlich wie Fundamentals of programming finals.ajang

Deguzmanpresentationprogramming
DeguzmanpresentationprogrammingDeguzmanpresentationprogramming
Deguzmanpresentationprogrammingdeguzmantrisha
 
Fundamentals of programming final santos
Fundamentals of programming final santosFundamentals of programming final santos
Fundamentals of programming final santosAbie Santos
 
Margareth lota
Margareth lotaMargareth lota
Margareth lotamaggybells
 
Fundamentals of programming final
Fundamentals of programming finalFundamentals of programming final
Fundamentals of programming finalRicky Recto
 
Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02thinesonsing
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 
Fundamentals of programming angeli
Fundamentals of programming angeliFundamentals of programming angeli
Fundamentals of programming angelibergonio11339481
 
Fundamentals of programming
Fundamentals of programmingFundamentals of programming
Fundamentals of programmingKaycee Parcon
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingChaAstillas
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinarurumedina
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)aeden_brines
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingaprilyyy
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kimkimberly_Bm10203
 

Ähnlich wie Fundamentals of programming finals.ajang (20)

Deguzmanpresentationprogramming
DeguzmanpresentationprogrammingDeguzmanpresentationprogramming
Deguzmanpresentationprogramming
 
Fundamentals of programming final santos
Fundamentals of programming final santosFundamentals of programming final santos
Fundamentals of programming final santos
 
Margareth lota
Margareth lotaMargareth lota
Margareth lota
 
Fundamentals of programming final
Fundamentals of programming finalFundamentals of programming final
Fundamentals of programming final
 
Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
My final requirement
My final requirementMy final requirement
My final requirement
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Fundamentals of programming angeli
Fundamentals of programming angeliFundamentals of programming angeli
Fundamentals of programming angeli
 
Fundamentals of programming
Fundamentals of programmingFundamentals of programming
Fundamentals of programming
 
Survelaine murillo ppt
Survelaine murillo pptSurvelaine murillo ppt
Survelaine murillo ppt
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kim
 

Fundamentals of programming finals.ajang

  • 2. http://en.wikipedia.org/wiki/Switch_statement http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_028.htm http://www.morrowland.com/apron/tutorials/cpp/cpp_switch_case/index.php http://eglobiotraining.com/
  • 4. - 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.
  • 5. 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) .
  • 6. 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 skipped Format of the if statement - All if statement examples in this text indent statements. The word else Is 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 http://eglobiotraining.com/
  • 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. http://eglobiotraining.com/
  • 8. 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/
  • 10. Link: http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_028.htm The above program uses a switch statement to validate and select upon the users input choice, simulating a simple menu of choices. http://eglobiotraining.com/
  • 11. When it compiles and run, this will be it look . The C expression that was type it on be it C++ . When it compiles and run, this will Dev look The words are “enter in two number  24”C++ The C expression that was type it on Dev The words are “enter in two number  24” http://eglobiotraining.com/
  • 12. Link: http://www.morrowland.com/apron/tutorials/cpp/cpp_switc Example of Switch Case Statement , you Will see the statement on the link that you see in this slide. http://eglobiotraining.com/
  • 13. 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. http://eglobiotraining.com/
  • 14. Link: http://www.morrowland.com/apron/tutorials/cpp/cpp_if_else/index.php Function and target of Programming language : and target of Programming Function A computer programming language : A computer programming language is a language. used to write computer programs,used to language is a language. which involve a computer performingwhich write computer programs, some kind of computation or algorithm some involve a computer performing and kind of computation or algorithm and possibly control external devices such possibly control external devices such as printers , disk drives , robots, and as printers , diskon. so drives , robots, and so on. http://eglobiotraining.com/
  • 15. When the statement was done this will it be look like. I got thisWhen the URL . The URL was posted onit be previous slide from the statement was done this will the look like. I got this from the URL . The URL was posted on the previous slide http://eglobiotraining.com/
  • 18. Link: http://www.cfanatic.com/topic4267/ http://eglobiotraining.com/
  • 21. 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://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  • 22. 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 http://eglobiotraining.com/
  • 23. 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/
  • 24. 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/
  • 25. Form: for {initialization; condition: increment ) { code to be executed } http://www.slideshare.net/ilakkiya/looping-statement http://eglobiotraining.com/
  • 26. 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://www.slideshare.net/ilakkiya/looping-statement } http://eglobiotraining.com/
  • 27. 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/
  • 28. “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/
  • 33. http://www.exforsys.com/tutorials/c-plus-plus/looping-in-c.html While loop http://eglobiotraining.com/
  • 35. http://cprogramminglanguage.net/c-break-continue-statements.aspx Break and continue http://eglobiotraining.com/
  • 37. http://www.w3schools.com/php/php_looping_for.asp Foreach loop http://eglobiotraining.com/
  • 38.
  • 39. Presented By: Marquez, Jaricka Angelyd B. BM10203