SlideShare a Scribd company logo
TRIVUz Academy

                             PF02
                 Class Id:




Programming Fundamentals
                              MS Alam TRIVUz
                                 Founder, TRIVUz Network
TRIVUz Academy
TRIVUz Academy




Recap PF01



             TRIVUz Academy
We learn before
                           We Define Computer & Program

                           Define Computer Programming

                                   Programming Process

                                 Programming Language

                                         Inputs & Outputs

                                Define Logical Processing

                                               Variables

                                              Data Types
Programming Fundamentals


 TRIVUz Academy

                                    www.trivuzacademy.com
We will learn today
                                  Conditional Statement

                                        If… then … else

                                       Switch statement

                                             Operators




Programming Fundamentals


 TRIVUz Academy
www.trivuzacademy.com
Conditional Statement
• Conditional statements are the set of
  command used to perform different
  actions base on different conditions
• In PHP we have the following conditional
  statements:
   • if
   • if else
   • else if
   • switch


                               TRIVUz Academy
If statement
        execute some code only if statement is true




TRIVUz Academy
If…




TRIVUz Academy
If…
  if




TRIVUz Academy
If…
  if (conditional)




TRIVUz Academy
If…
  if (conditional) {




TRIVUz Academy
If…
  if (conditional) {
   // statement to be executed




TRIVUz Academy
If…
  if (conditional) {
   // statement to be executed
  }




TRIVUz Academy
If…
  Example:

  if ($math < 33) {
    $result = “Failed!”;
  }




TRIVUz Academy
If…else statement
          execute some code if statement is true
         and some other code if statement is false




TRIVUz Academy
If…else…
  if (conditional) {
   // statement if true
  }




TRIVUz Academy
If…else…
  if (conditional) {
   // statement if true
  } else




TRIVUz Academy
If…else…
  if (conditional) {
   // statement if true
  } else {
   // statement if false




TRIVUz Academy
If…else…
  if (conditional) {
   // statement if true
  } else {
   // statement if false
  }




TRIVUz Academy
If…else…
  Example:

  if ($math < 33) {
    $result = “Failed!”;
  } else {
    $result = “Passed!”;
  }




TRIVUz Academy
If…else if…else statement
          execute some code if statement is true
         And some other code if statement is false




TRIVUz Academy
If…else if…else
  if (conditional) {
   // statement if true
  } else if (conditional){
   // statement if false and else if true
  } else {
   // statement if all false
  }


TRIVUz Academy
If…else if…else
      if (conditional) {
         // statement if true
       } else if (conditional){
         // whichever matches first
       } else if (conditional){
         // whichever matches first
       } else if (conditional){
         // whichever matches first
       } else if (conditional){
         // whichever matches first
       } else {
         // statement if all false
      }

TRIVUz Academy
If…else if…else
  Example:

    if ($avg > 100) {
        $grade = "Invalid";
    }
    else if ($avg > 90 and $avg < 100 ) {
        $grade = "A+";
    }
    else if($avg > 80 and $avg < 90) {
        $grade = "A";
    }
    else {
        $grade = "F";
    }

TRIVUz Academy
switch statement
       Select one of many block of code to execute




TRIVUz Academy
switch
  switch




TRIVUz Academy
switch
  switch (value)




TRIVUz Academy
switch
  switch (value) {




TRIVUz Academy
switch
  switch (value) {
   case 1:
    // some code to execute




TRIVUz Academy
switch
  switch (value) {
   case 1:
    // some code to execute
    break;




TRIVUz Academy
switch
  switch (value) {
   case 1:
    // some code to execute
    break;
   case 2:
    // some code to execute
    break;



TRIVUz Academy
switch
  switch (value) {
   case 1:
    // some code to execute
    break;
   case 2:
    // some code to execute
    break;
   default:
    // nothing matches, do it

TRIVUz Academy
switch
  switch (value) {
   case 1:
    // some code to execute
    break;
   case 2:
    // some code to execute
    break;
   default:  similar to else in if..else
    // nothing matches, do it

TRIVUz Academy
switch
  switch (value) {
    case 1:
     // some code to execute
     break;
    case 2:
     // some code to execute
     break;
    default:
     // nothing matches, do it
  }
TRIVUz Academy
switch
switch (n)
{
case label1:
  code to be executed if n=label1;
  break;
case label2:
  code to be executed if n=label2;
  break;
default:
  code to be executed if n is different from both label1
and label2;
}

                                          TRIVUz Academy
switch
<html>
<body>
<?php
    switch ($x)
    {
      case 1:
        echo "Number 1";
      break;
      case 2:
        echo "Number 2";
      break;
      case 3:
        echo "Number 3";
      break;
      default:
        echo "No number between 1 and 3";
   }
?>
</body>
                                            TRIVUz Academy
</html>
PHP Operators
         Operators are used to operate on values




TRIVUz Academy
Operators
Arithmetic Operators




            TRIVUz Academy
Operators
Assignment Operators




             TRIVUz Academy
Operators
Comparison Operators




             TRIVUz Academy
Operators
Logical Operators




         TRIVUz Academy
Thank You



            MS Alam TRIVUz
            Founder,
            TRIVUz Academy
            trivuz@gmail.com

More Related Content

PPTX
1.4 core programming [understand error handling]
PPTX
programming c language.
PPTX
Data structures vb
PPT
02 Symbian Os Basics Tipos De Dados
PPTX
Looping and switch cases
PPT
M C6java5
PPTX
Java loops for, while and do...while
1.4 core programming [understand error handling]
programming c language.
Data structures vb
02 Symbian Os Basics Tipos De Dados
Looping and switch cases
M C6java5
Java loops for, while and do...while

What's hot (20)

PPTX
Statements and Conditions in PHP
PDF
09 ruby if else
PPTX
Exception handling
PPTX
Exception Handling in object oriented programming using C++
PPTX
Java Decision Control
PPT
M C6java6
PPTX
Cse lecture-6-c control statement
PPTX
Constructs (Programming Methodology)
PPTX
Decision Making Statement in C ppt
PPTX
Looping and Switchcase BDCR
PPTX
Exception handling c++
PPTX
Using loops
PPTX
Iteration Statement in C++
DOC
Jumping statements
PPT
Decision making and branching
PPTX
Exception handling in c++
PPT
Exception handling
PPT
Mesics lecture 6 control statement = if -else if__else
PDF
Chapter 8 - Conditional Statement
PPTX
Vb decision making statements
Statements and Conditions in PHP
09 ruby if else
Exception handling
Exception Handling in object oriented programming using C++
Java Decision Control
M C6java6
Cse lecture-6-c control statement
Constructs (Programming Methodology)
Decision Making Statement in C ppt
Looping and Switchcase BDCR
Exception handling c++
Using loops
Iteration Statement in C++
Jumping statements
Decision making and branching
Exception handling in c++
Exception handling
Mesics lecture 6 control statement = if -else if__else
Chapter 8 - Conditional Statement
Vb decision making statements
Ad

Viewers also liked (20)

PDF
Conditional Statements | If-then Statements
PPT
Conditional Statements
PPSX
Conditional statement
PPTX
C if else
PPTX
CONDITIONAL STATEMENT IN C LANGUAGE
PDF
Octal and Hexadecimal Numbering Systems
PDF
Binary octal
PDF
1.3.2 Conditional Statements
PPT
Conditional Statements
PDF
Using the IF Function in Excel
PPTX
Conditional statements
PPTX
11 octal number system
PPT
1st Test - If then, converse, inverse and contrapositive
PPT
Excel IF function
PPTX
Number system conversion
PPTX
Introduction number systems and conversion
PPTX
Number System
PPTX
Loops in C
PPSX
Number system
PPTX
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Conditional Statements | If-then Statements
Conditional Statements
Conditional statement
C if else
CONDITIONAL STATEMENT IN C LANGUAGE
Octal and Hexadecimal Numbering Systems
Binary octal
1.3.2 Conditional Statements
Conditional Statements
Using the IF Function in Excel
Conditional statements
11 octal number system
1st Test - If then, converse, inverse and contrapositive
Excel IF function
Number system conversion
Introduction number systems and conversion
Number System
Loops in C
Number system
Logic gates - AND, OR, NOT, NOR, NAND, XOR, XNOR Gates.
Ad

Similar to Programming Basics if then else, switch, operators (20)

PPTX
PHP Lecture 02.pptx PHP Lecture 02 .pptx
PDF
conditional_statement.pdf
PPT
Chapter 4 flow control structures and arrays
PPTX
Final project powerpoint template (fndprg) (1)
PDF
Lecture 8
PPTX
05. Conditional Statements
PDF
Chapter 00 revision
PDF
OIT 116 LOOPS AND CONDITION STATEMENTS.pdf
PPTX
Control Statement programming
PDF
Loops and conditional statements
PPT
Java_Tutorial_Introduction_to_Core_java.ppt
PPT
Java Tutorial
PPT
Javatut1
PPT
Java tut1 Coderdojo Cahersiveen
PPT
Java tut1
PPT
Java tut1
PPT
Java tutorial PPT
PPT
Java tutorial PPT
PPT
Java teaching ppt for the freshers in colleeg.ppt
PPTX
control_javascript_for _beginners_and _pro.pptx
PHP Lecture 02.pptx PHP Lecture 02 .pptx
conditional_statement.pdf
Chapter 4 flow control structures and arrays
Final project powerpoint template (fndprg) (1)
Lecture 8
05. Conditional Statements
Chapter 00 revision
OIT 116 LOOPS AND CONDITION STATEMENTS.pdf
Control Statement programming
Loops and conditional statements
Java_Tutorial_Introduction_to_Core_java.ppt
Java Tutorial
Javatut1
Java tut1 Coderdojo Cahersiveen
Java tut1
Java tut1
Java tutorial PPT
Java tutorial PPT
Java teaching ppt for the freshers in colleeg.ppt
control_javascript_for _beginners_and _pro.pptx

More from Trivuz ত্রিভুজ (6)

PPTX
Web design basics 1
PPTX
PPTX
Database - Design & Implementation - 1
PPTX
Programming Basics - array, loops, funcitons
PPTX
Programming Fundamentals
PPTX
Running @ maximum HP without Tearing Apart
Web design basics 1
Database - Design & Implementation - 1
Programming Basics - array, loops, funcitons
Programming Fundamentals
Running @ maximum HP without Tearing Apart

Recently uploaded (20)

PDF
Pre independence Education in Inndia.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Business Ethics Teaching Materials for college
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Classroom Observation Tools for Teachers
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Complications of Minimal Access Surgery at WLH
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
master seminar digital applications in india
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
Pre independence Education in Inndia.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Business Ethics Teaching Materials for college
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
VCE English Exam - Section C Student Revision Booklet
Classroom Observation Tools for Teachers
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPH.pptx obstetrics and gynecology in nursing
TR - Agricultural Crops Production NC III.pdf
Cell Types and Its function , kingdom of life
01-Introduction-to-Information-Management.pdf
Week 4 Term 3 Study Techniques revisited.pptx
O7-L3 Supply Chain Operations - ICLT Program
Anesthesia in Laparoscopic Surgery in India
Complications of Minimal Access Surgery at WLH
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Pharmacology of Heart Failure /Pharmacotherapy of CHF
master seminar digital applications in india
Module 4: Burden of Disease Tutorial Slides S2 2025

Programming Basics if then else, switch, operators

  • 1. TRIVUz Academy PF02 Class Id: Programming Fundamentals MS Alam TRIVUz Founder, TRIVUz Network TRIVUz Academy
  • 2. TRIVUz Academy Recap PF01 TRIVUz Academy
  • 3. We learn before We Define Computer & Program Define Computer Programming Programming Process Programming Language Inputs & Outputs Define Logical Processing Variables Data Types Programming Fundamentals TRIVUz Academy www.trivuzacademy.com
  • 4. We will learn today Conditional Statement If… then … else Switch statement Operators Programming Fundamentals TRIVUz Academy www.trivuzacademy.com
  • 5. Conditional Statement • Conditional statements are the set of command used to perform different actions base on different conditions • In PHP we have the following conditional statements: • if • if else • else if • switch TRIVUz Academy
  • 6. If statement execute some code only if statement is true TRIVUz Academy
  • 8. If… if TRIVUz Academy
  • 9. If… if (conditional) TRIVUz Academy
  • 10. If… if (conditional) { TRIVUz Academy
  • 11. If… if (conditional) { // statement to be executed TRIVUz Academy
  • 12. If… if (conditional) { // statement to be executed } TRIVUz Academy
  • 13. If… Example: if ($math < 33) { $result = “Failed!”; } TRIVUz Academy
  • 14. If…else statement execute some code if statement is true and some other code if statement is false TRIVUz Academy
  • 15. If…else… if (conditional) { // statement if true } TRIVUz Academy
  • 16. If…else… if (conditional) { // statement if true } else TRIVUz Academy
  • 17. If…else… if (conditional) { // statement if true } else { // statement if false TRIVUz Academy
  • 18. If…else… if (conditional) { // statement if true } else { // statement if false } TRIVUz Academy
  • 19. If…else… Example: if ($math < 33) { $result = “Failed!”; } else { $result = “Passed!”; } TRIVUz Academy
  • 20. If…else if…else statement execute some code if statement is true And some other code if statement is false TRIVUz Academy
  • 21. If…else if…else if (conditional) { // statement if true } else if (conditional){ // statement if false and else if true } else { // statement if all false } TRIVUz Academy
  • 22. If…else if…else if (conditional) { // statement if true } else if (conditional){ // whichever matches first } else if (conditional){ // whichever matches first } else if (conditional){ // whichever matches first } else if (conditional){ // whichever matches first } else { // statement if all false } TRIVUz Academy
  • 23. If…else if…else Example: if ($avg > 100) { $grade = "Invalid"; } else if ($avg > 90 and $avg < 100 ) { $grade = "A+"; } else if($avg > 80 and $avg < 90) { $grade = "A"; } else { $grade = "F"; } TRIVUz Academy
  • 24. switch statement Select one of many block of code to execute TRIVUz Academy
  • 26. switch switch (value) TRIVUz Academy
  • 27. switch switch (value) { TRIVUz Academy
  • 28. switch switch (value) { case 1: // some code to execute TRIVUz Academy
  • 29. switch switch (value) { case 1: // some code to execute break; TRIVUz Academy
  • 30. switch switch (value) { case 1: // some code to execute break; case 2: // some code to execute break; TRIVUz Academy
  • 31. switch switch (value) { case 1: // some code to execute break; case 2: // some code to execute break; default: // nothing matches, do it TRIVUz Academy
  • 32. switch switch (value) { case 1: // some code to execute break; case 2: // some code to execute break; default:  similar to else in if..else // nothing matches, do it TRIVUz Academy
  • 33. switch switch (value) { case 1: // some code to execute break; case 2: // some code to execute break; default: // nothing matches, do it } TRIVUz Academy
  • 34. switch switch (n) { case label1: code to be executed if n=label1; break; case label2: code to be executed if n=label2; break; default: code to be executed if n is different from both label1 and label2; } TRIVUz Academy
  • 35. switch <html> <body> <?php switch ($x) { case 1: echo "Number 1"; break; case 2: echo "Number 2"; break; case 3: echo "Number 3"; break; default: echo "No number between 1 and 3"; } ?> </body> TRIVUz Academy </html>
  • 36. PHP Operators Operators are used to operate on values TRIVUz Academy
  • 40. Operators Logical Operators TRIVUz Academy
  • 41. Thank You MS Alam TRIVUz Founder, TRIVUz Academy trivuz@gmail.com

Editor's Notes

  • #3: ----- Meeting Notes (12/28/11 19:20) -----