Running the script with stdin and stdout redirected will do that:
Code:
./assign3.exe < infile > outfile
You can also perform the redirection inside the script. In that case, use
> to write the first line to "outfile" (it will overwrite the file if it exists), and then use
>> if you wish to add further data to the file:
Code:
echo Length= $foo Width= $bar Area= $baz > outfile
echo ...more text... >> outfile