Upcoming SlideShare
×

# Programming Basics if then else, switch, operators

3,451 views

Published on

Published in: Education, Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
3,451
On SlideShare
0
From Embeds
0
Number of Embeds
1,201
Actions
Shares
0
54
0
Likes
0
Embeds 0
No embeds

No notes for slide
• ----- Meeting Notes (12/28/11 19:20) -----
• ### Programming Basics if then else, switch, operators

1. 1. TRIVUz Academy PF02 Class Id:Programming Fundamentals MS Alam TRIVUz Founder, TRIVUz NetworkTRIVUz Academy
3. 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. 4. We will learn today Conditional Statement If… then … else Switch statement OperatorsProgramming Fundamentals TRIVUz Academywww.trivuzacademy.com
5. 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. 6. If statement execute some code only if statement is trueTRIVUz Academy
9. 9. If… if (conditional)TRIVUz Academy
10. 10. If… if (conditional) {TRIVUz Academy
11. 11. If… if (conditional) { // statement to be executedTRIVUz Academy
12. 12. If… if (conditional) { // statement to be executed }TRIVUz Academy
13. 13. If… Example: if (\$math < 33) { \$result = “Failed!”; }TRIVUz Academy
14. 14. If…else statement execute some code if statement is true and some other code if statement is falseTRIVUz Academy
15. 15. If…else… if (conditional) { // statement if true }TRIVUz Academy
16. 16. If…else… if (conditional) { // statement if true } elseTRIVUz Academy
17. 17. If…else… if (conditional) { // statement if true } else { // statement if falseTRIVUz Academy
18. 18. If…else… if (conditional) { // statement if true } else { // statement if false }TRIVUz Academy
19. 19. If…else… Example: if (\$math < 33) { \$result = “Failed!”; } else { \$result = “Passed!”; }TRIVUz Academy
20. 20. If…else if…else statement execute some code if statement is true And some other code if statement is falseTRIVUz Academy
21. 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. 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. 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. 24. switch statement Select one of many block of code to executeTRIVUz Academy
26. 26. switch switch (value)TRIVUz Academy
27. 27. switch switch (value) {TRIVUz Academy
28. 28. switch switch (value) { case 1: // some code to executeTRIVUz Academy
29. 29. switch switch (value) { case 1: // some code to execute break;TRIVUz Academy
30. 30. switch switch (value) { case 1: // some code to execute break; case 2: // some code to execute break;TRIVUz Academy
31. 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. 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. 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. 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. 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. 36. PHP Operators Operators are used to operate on valuesTRIVUz Academy
37. 37. OperatorsArithmetic Operators TRIVUz Academy
38. 38. OperatorsAssignment Operators TRIVUz Academy
39. 39. OperatorsComparison Operators TRIVUz Academy
40. 40. OperatorsLogical Operators TRIVUz Academy
41. 41. Thank You MS Alam TRIVUz Founder, TRIVUz Academy trivuz@gmail.com