Histogram area ...why not working

only this much was the algorithm…
something missed out orrr ???
help

you also have to do some work outside the loop if stack is not empty

inside loop instead of if you have to use while loop
see the modified Code
Modified Code