You can do this quite easily with a shell script and internal string manipulation - no need to invoke other processes:
Code:
#!/bin/bash
read -p "enter the IP> " ip
slash24root="${ip%.*}"
gateway="$slash24root.1"
network="$slash24root.0"
broadcast="$slash24root.255"
printf "%-20s = %s\n" "ip" "$ip"
printf "%-20s = %s\n" "gateway" "$gateway"
printf "%-20s = %s\n" "network" "$network"
printf "%-20s = %s\n" "broadcast" "$broadcast"