Delay-and-sum beamforming: implementing steering in C
The code is calculating the beam pattern of a linear array which is the response at a single frequency.You might note that no actual sensor data is being summed or delayed.

The pattern is defined over all the angles from -90 to 90 and will have a main lobe. 

There are essentially two ways of steering a beam, by multiplication by phase at a single frequency or by actually delaying the signal in the time domain, typically using a N point interpolation, where N is small.

For 4 elements,  500 hundred look directions is rather too much.