Monday 5 July 2010

Write an algorithm to display day of week using switch case

1.Start
2.Declare the variable week
3.Ask the user to enter numbers from 1 to 3
4.Read the value and store into variable week
5. Use switch case check whether week=1 then go to step 6
   else go to step 20.
6. Print "Monday" Go to step 7
7. Use break statement to come out the switch case
8. Check whether week=2 then go to step 9 else go to step 20.
9. Print "Tuesday", then go to step 10.
10. Use break statement to come out of the switch case
11. Check whether week=3 then go to step 12 else go to step 20
12. Print "Wed", Go to step 13.
13. Use break statement to come out of the swith case.
14. Use default to print invalid if week number is above 3
20. Stop

You may like the following posts:
Switch statement

No comments:

Post a Comment