Percentage calculation

i am trying to get percentage : but not able to do it:

i tried :
x=1
y=2
z=`expr $x/$y*100`

it is not giving me result

can u pls help on this

try multiplying by 100 first:

z=$((100*$x/$y))

or alternatively use bc :

z=$(echo "scale=2 ; ($x/$y*100)" | bc)

i tried it :

z=$(echo "scale=4 ; ($x/$y*100)" | bc)

bt it is giving result : 33.3300
x=1
y=3

i want 33.33

That's because you set scale to '4' which is the number of digits right of the decimal point... So leave scale to '2' and it should work.

it is coming 33.00

i need 33.33

how i will do it ?