Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- echo -n "Enter the size of the arrays: "
- read n
- echo -n "Enter the first array: "
- read -a a
- if [ ${#a[@]} -ne $n ]; then
- echo "Array not of specified length."
- exit 1
- fi
- echo -n "Enter the second array: "
- read -a b
- if [ ${#b[@]} -ne $n ]; then
- echo "Array not of specified length."
- exit 1
- fi
- for(( i=0; i<$n; i++ )){
- add[$i]=$((a[i]+b[i]));
- sub[$i]=$((a[i]-b[i]));
- mul[$i]=$((a[i]*b[i]));
- }
- echo "The addition array is "${add[*]}
- echo "The subtraction array is "${sub[*]}
- echo "The multiplication array is "${mul[*]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement