🚀 Code smarter. Crack exams faster. Free AI-powered learning on Leyaa.ai →

Shell script for division of two numbers

1. initialize two variables

2. divide two numbers directly using $(...) or by using external program expr.

3. Echo the final result.




Division of two numbers without using expr

#Unix shell script for the division of two numbers

num1=100
num2=20

ans=$((num1 / num2))

echo $ans

Output

5




Division of two numbers using expr in shell script

#Unix shell script for division of two numbers
#using expr

num1=100
num2=20

ans=`expr $num1 / $num2`

echo $ans

Output

5


🚀 One platform. 90+ coding courses. 200+ exams.

From programming fundamentals to competitive exam prep — learn with intelligence, not just content. Free on Leyaa.

Explore Leyaa.ai Free →

Topics You Might Like