TCS OPA UNIX Solution 8 May
Q. Write a shell
script to find the difference between sum of squares of Even and sum of
the squares of Odd numbers in the given list.
#!/bin/bash
read
awk 'BEGIN{e=0;o=0} {if ($0%2==0) {e+=$0*$0} else { o+=$0*$0}} END{print (e-o)}'
read
awk 'BEGIN{e=0;o=0} {if ($0%2==0) {e+=$0*$0} else { o+=$0*$0}} END{print (e-o)}'
Comments
Post a Comment