Write a shell program to test whether a given number is even
or odd?

Answer Posted / mani

echo "Enter the Number"
read a
b=`echo "$a % 2"|bc`
if [ $b -eq 0 ]
then
echo "Given Number is Even "
exit
fi
echo " Given Number is odd"

Is This Answer Correct ?    67 Yes 34 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to get part of string variable with echo command only?

594


What is the best scripting language?

568


What is a shell script in windows?

590


How can we find the process name from its process id?

711


What is shell scripting?

595






Rewrite the command to print the sentence and convert the variable to plural: echo “i like $variable”.

575


How to get the first line from a file using just the terminal?

599


Explain about stdin, stdout and stderr?

637


What is an inode block?

579


How do I run a script on mac?

572


Calculate a real number calculation directly from the terminal and not any shell script.

664


What is sh in shell script?

577


Why is used in shell scripting?

562


Is shell scripting difficult?

559


What are scripts in psychology?

601