June 2017
Beginner
502 pages
11h 26m
English
With modulo assignment, we divide the value of the variable for a given number and reassign the remainder. Let's just modify a couple of lines in our script:
echo "The value of ${user_input} divided by ${adding} is: $((user_input/=adding))"echo "The remainder of ${user_input} divided by ${adding} is: $((user_input%=adding))"
And execute it:
zarrelli@:~$ ./userreassign-modulo.sh Hello user, please give me a number: 324And now another one, please: 12The user_input variable value is: 324The adding variable value is: 12The value of 324 divided by 12 is: 27The remainder of 27 divided by 12 is: 3And the user_input variable has now the value of 3But the adding variable has still the value of 12
Read now
Unlock full access