Algorithm
Step 1 : Start
Step 2 : Read age
Step 3 : If age 17
Print "Not eligible to vote"
Step 3.1 : else
Print "Eligible to vote"
Step 4 : Stop
Program
# Vote--range matching
echo -n "Enter your age : "
read age
case $age in
[0-9]|1[0-7])echo "You are not eligible to vote";;
*)echo "Eligible to vote"
esac
Output
[vijai@localhost multway]$ sh vote.sh
Enter your age : 12
You are not eligible to vote
Step 1 : Start
Step 2 : Read age
Step 3 : If age 17
Print "Not eligible to vote"
Step 3.1 : else
Print "Eligible to vote"
Step 4 : Stop
Program
# Vote--range matching
echo -n "Enter your age : "
read age
case $age in
[0-9]|1[0-7])echo "You are not eligible to vote";;
*)echo "Eligible to vote"
esac
Output
[vijai@localhost multway]$ sh vote.sh
Enter your age : 12
You are not eligible to vote
No comments:
Post a Comment