Input a day number and display the name of the day.(If number is 1 output should be monday,if it is 2 output should be Tuesday etc . ) if the no is other than 1 to 7 display as invalid day.Design an algorithm and flowchart for it. Plz give me answer.I wll mark u as brainlist.Question is from Computer Application Class11
Answers
Answered by
16
algorithm for printing day of week by taking number from 1 to 7
Attachments:
Answered by
3
Given below is the required algorithm for displaying the number corresponding to each day.
Explanation:
- Declare two variables 'n' and 'd'
- Variable 'n' is type int and variable 'd' is type string,
- Take user input for the number of the day in variable 'n'.
- If 'n' is equal to 1 assign 'd' the value 'Monday'.
- If 'n' is equal to 2 assign 'd' the value 'Tuesday'.
- If 'n' is equal to 3 assign 'd' the value 'Wednesday'.
- If 'n' is equal to 4 assign 'd' the value 'Thursday'.
- If 'n' is equal to 5 assign 'd' the value 'Friday'.
- If 'n' is equal to 6 assign 'd' the value 'Saturday'.
- If 'n' is equal to 7 assign 'd' the value 'Sunday'.
- if 'n' is equal to any other value print "Invalid day number."
- print d.
Similar questions