#!/usr/bin/csh #File's name: arithmetic.csh #Author: Jen Chen #Updated on: 08/12/04 #Copyrighted by Jen Chen #Caution: Only integer arithmetic is allowed in C-shell scripting!!! set USAGE="arithmetics.csh num num2; where num and num2 are integers." #Check to see if the user passes the 2 integers from the command line. if($#argv < 2)then echo "$USAGE" exit 1 endif #Set the variables num and num2 to be the values passing from the #command line. set num = $argv[1] set num2 = $argv[2] echo $num echo $num2 #In order to do mathematical computation in C-shell, we need to place the @ @sign at the beginning of each statemnent containing the operation. @ sum = $num + $num2 echo "$num + $num2 = " $sum @ dif = $num - $num2 echo "$num - $num2 = " $dif @ prod = $num * $num2 @ div = $num / $num2 echo "$num / $num2 = " $div @ modu = $num % $num2 #compute modulo n echo "$num % $num2 = " $modu #Now release the memories back to your OS. unset num num2 junk USAGE