Exp2 B

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

SAMPLE INPUT AND OUTPUT:

*****Odd or Even*****

Enter a number : 33
45 is an Odd number

Enter a number : 18
18 is an Even number
EX.NO : 2.b) SHELL PROGRAMMING
Odd or Even
DATE :

AIM:
To write the simple shell programs by using conditional, branching and looping statements.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Read the value of n.

STEP 3: Calculate ‘r = expr $n%2’.


STEP 4: If the value of r equals to 0 then print the number is even.
STEP 5: If the value of r not equal to 0 then print the number is odd.
PROGRAM:
echo “*****Odd or Even*****”

while:
do
read –p “Enter a number : “ n
if [ $((n%2)) -eq 0 ]
then
echo “$n is an Even number”
else
echo “$n is an Odd number”
fi
done

RESULT :
Thus the program was Executed and Verified Successfully.

You might also like