why this code is wrong?
#include<stdio.h>
main()
{
float a,s=1,t=1,k=0;
int n,i,j,d=1;
printf("\n\n Enter the number of the terms of the table: ");
scanf("%d",&n);
float y[] = {
8.000,7.500,7.000,6.500,6.000,5.500,5.000, 4.500, 4.000, 3.500, 3.000, 2.500,
2.000, 1.500, 1.000, 0.500, 0.001
};
float x[]=
{
77.1432,77.1683,77.2058,77.2836,77.3311,77.4015, 77.5143, 77.6367, 77.7765,
77.9419, 78.1841, 78.4707, 78.8471, 79.3543, 79.9213, 80.6832, 81.5339
};
printf("\n\n The table you entered is as follows :\n\n");
for(i=0; i<n; i++)
{
printf("%0.3f\t%0.3f",x[i],y[i]);
printf("\n");
}
while(d==1)
{
printf(" \n\n\n Enter the value of the x to find the respective value of y\n\n\n");
scanf("%f",&a);
for(i=0; i<n; i++)
{
s=1;
t=1;
for(j=0; j<n; j++)
{
if(j!=i)
{
s=s*(a-x[j]);
t=t*(x[i]-x[j]);
}
}
k=k+((s/t)*y[i]);
}
printf("\n\n The respective value of the variable y is: %f",k);
printf("\n\n Do you want to continue?\n\n Press 1 to continue and any other key to exit");
scanf("%d",&d);
}
}
for values of input x for which i want the corrispondent y near to the last memper of x[] it give me random values.
Please help me