How do I calculate total number of active and non active hosts?

#!/bin/bash
for digit in $(seq 1 10)
do 
if ping -c1 -w2 192.168.1.$digit &> /dev/null 
then 
echo "192.168.1.$digit is UP"
else
echo "192.168.1.$digit is DOWN"
fi 
done

As you are using bash, shell arithmetics are at your disposal. Put a (( cnt++ )) into the then branch for active nodes.

Currently I using bash.

I am able to calculate only one echo but I am not able to sum up the whole thing. Inside the echo itself has a variable which arises to different value.

Sorry? If you run your loop over the 10 hosts in your code snippet, for every host responding it will execute the then branch and increment cnt in there, so cnt will hold the No. of active hosts afterwards. Did you give it a shot, after all?