Your SlideShare is downloading. ×
Programming Basics if then else, switch, operators
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Programming Basics if then else, switch, operators

2,883
views

Published on

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,883
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
42
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • ----- Meeting Notes (12/28/11 19:20) -----
  • Transcript

    • 1. TRIVUz Academy PF02 Class Id:Programming Fundamentals MS Alam TRIVUz Founder, TRIVUz NetworkTRIVUz Academy
    • 2. TRIVUz AcademyRecap 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 TypesProgramming Fundamentals TRIVUz Academy www.trivuzacademy.com
    • 4. We will learn today Conditional Statement If… then … else Switch statement OperatorsProgramming Fundamentals TRIVUz Academywww.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 trueTRIVUz Academy
    • 7. If…TRIVUz Academy
    • 8. If… ifTRIVUz Academy
    • 9. If… if (conditional)TRIVUz Academy
    • 10. If… if (conditional) {TRIVUz Academy
    • 11. If… if (conditional) { // statement to be executedTRIVUz 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 falseTRIVUz Academy
    • 15. If…else… if (conditional) { // statement if true }TRIVUz Academy
    • 16. If…else… if (conditional) { // statement if true } elseTRIVUz Academy
    • 17. If…else… if (conditional) { // statement if true } else { // statement if falseTRIVUz 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 falseTRIVUz 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 executeTRIVUz Academy
    • 25. switch switchTRIVUz Academy
    • 26. switch switch (value)TRIVUz Academy
    • 27. switch switch (value) {TRIVUz Academy
    • 28. switch switch (value) { case 1: // some code to executeTRIVUz 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 itTRIVUz 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 itTRIVUz 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. switchswitch (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 label1and 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 valuesTRIVUz Academy
    • 37. OperatorsArithmetic Operators TRIVUz Academy
    • 38. OperatorsAssignment Operators TRIVUz Academy
    • 39. OperatorsComparison Operators TRIVUz Academy
    • 40. OperatorsLogical Operators TRIVUz Academy
    • 41. Thank You MS Alam TRIVUz Founder, TRIVUz Academy trivuz@gmail.com