Addition of two variables in shell script - CodexRitik

Addition of two variables in shell script 

1. initialize two variables
2. Add two variables directly using $(...) or by using external program expr
3. Echo the final result.
  • Code:
#Shell Program To Add Two Numbers Using expr if Value Already Given
num1=20
num2=10     #Don't Give between space
sum=` expr $num1 + $num2 `
echo "Sum Of Two Numbers : $sum"
  • Output:
Sum Of Two Numbers : 30

  • Click For Image View------
                                                           
sum of two numbers in shell



🙏THANKS FOR VISIT🙏


Addition of two variables in shell script - CodexRitik Addition of two variables in shell script - CodexRitik Reviewed by CodexRitik on July 11, 2020 Rating: 5

No comments:

Powered by Blogger.