Why ups and downs of amplitude? Ladies, Gentlemen,
Please let me again employee you with my problems. In following program there is only one sinusoid with frequency 256 Hz amplitude 100,000 and phase 0.67 pi rad. Testing frequencies grid is of 1 Hz step, from 0 Hz to 1000 Hz. Output has maximum amplitude 99,221 and phase 0.670561 pi rad at 256 Hz. I regard it okay given errors in accuracy. 

But there are ups and downs in pseudo-frequencies amplitude while my understanding about DFT is that they should going upward till 256 Hz and then downward. Why these ups and downs? I remain with regards. 

// Grid is created by variables lowTestFreq and testFreqStep
// both of double type, and integer type M.
// In comments are units of variables.

#include &lt;iostream&gt;
#include "math.h"

int main()
{  
    //Unchanged variables.
    double pi = 3.141592653589793; //pure number.
    int n = 0; // sample.
    double xn = 0; //pure number.
    double Re = 0; //pure number.
    double Im = 0; //pure number.
    double xn_cos = 0; //pure number.
    double xn_sin = 0; //pure number.
    double testAmpl = 0; // pure number.
    double testPhase = 0; // rad and then pirad.   

    //Sampling frequency and samples of segment.
    int samplFreq = 50000; // sample/second.
    int N = 3000; //sample.

    // Existing sinusoid.
    double ampl_1 = 100000; //pure number.
    double existFreq_1 = 256; // Hz.
    double phase_1 = 0.67 * pi; // rad.
    double unitAngle_1 = (existFreq_1 / samplFreq) * (2 * pi); // rad/sample.

    // Testing grid.
    double testFreq = 0; // Hz.
    double testUnitAngle = 0; // rad.
    double testAngle = 0; // 
    double lowTestFreq = 0; //Hz.
    double testFreqStep = 1; // Hz.
    int M = 1000; // pure number.
    int m = 0; // pure number.

    for (m = 0; m &lt;= M; ++m)
    {
        testFreq = lowTestFreq + (m * testFreqStep); // Hz.
        testUnitAngle = (testFreq / samplFreq) * (2 * pi); // rad/sample.

        Re = 0; Im = 0;

        for (n = 1; n &lt;= N; ++n)
        {
            xn = ampl_1 * sin(n * unitAngle_1 + phase_1);

            testAngle = n * testUnitAngle;
            xn_cos = xn *  cos(testAngle);
            xn_sin = xn * -sin(testAngle);

            Re += xn_cos;
            Im += xn_sin;
        }  
        std::cout &lt;&lt; "Test Freq " &lt;&lt; testFreq; // Hz.
        testAmpl = sqrt(Re * Re + Im * Im) / N * 2; //pure number.       
        std::cout &lt;&lt; "       Test Freq's Ampl: " &lt;&lt; testAmpl;
        testPhase = atan2 (Im, Re); // rad.
        testPhase = testPhase / pi; // pirad.
        testPhase = testPhase + 0.5; // pirad. Corrected phase.
        std::cout &lt;&lt; ",    and its phase: " &lt;&lt; testPhase 
            &lt;&lt; " pirad." &lt;&lt; std::endl;
    }       
    return 0;
}
A DFT includes an implicit finite length window on any function (which has an infinite domain in the case of a sinusoid).  The effect of multiplication by that window in the time domain on the DFT result is a convolution with the transform of that window.  In the case of a rectangular window, that looks like something very close to a Sinc function (except near DC or Fs/2), or sin(w)/w (which has lots of "ups and downs".)