Result Difference between int and float in Generic Function
<p>Compile and run my code; compare the result if you are using integers or floats with fractional values. Why is there a difference?</p>

<p>Here is my code:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

template&lt;class T&gt;

T find(T array[], T len, T num){    
    for (int i = 0; i &lt; len; ++i){
        if (array[i] == num) 
             return i;
    }
    return -1;
}

int main () {  
    int array1[5] = { 4, 7, 3, 5, 6 }, num1;
    float array2[5] ={121.2, 111.5, 300.1, 500.1, 600.1 }, num2;

    cout &lt;&lt; "Enter an int:" &lt;&lt; " " ;
    cin &gt;&gt; num1;

    cout &lt;&lt; "Enter a float:" &lt;&lt; " " ;
    cin &gt;&gt; num2;        

    int x = find&lt;int&gt;(array1,5,num1);
    float y= find&lt;float&gt;(array2,5,num2); 

    cout &lt;&lt; "The index for the int is:" &lt;&lt; "  " &lt;&lt; x &lt;&lt; endl;         
    cout &lt;&lt; "The index for the float is:" &lt;&lt; "  " &lt;&lt; y &lt;&lt; endl;

    return 0;
}
</code></pre>

<p>I couldn't find the difference between the two results when using ints and when using floats.</p>
