Answer to Question #254185 in UNIX/Linux Programming for Man

Question #254185
Write a script in Ubuntu to print odd and even number from any range.
Hint: (num%2==0) even else it's odd
1
Expert's answer
2021-10-20T16:38:15-0400

echo "enter n value as range to calculate odd and even numbers."

read n

i=1

while [ $i -le $n ]

do

if [ `expr $i % 2` -eq 0 ]

then

echo even=$i

else

echo odd=$i

fi

i=`expr $i + 1`

done


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS