general2012 0 Junior Poster in Training

hi, after a long time been posting in this forum.I am trying to manipulate newtons divide difference formula ,actually like this see it here
but in a different manner .but my code is not working.i am getting disgusting values in my table.can any one please check the errors and tell me what it is .my code is like this.Thanks !!!!!

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
    int x[10],p,i,n,m,k,j;
    float y[6][5];
    printf("how many numbers?");
    scanf("%d",&n);
    for(i=0;i<n;i++){
                     scanf("%d",&x[i]);
                     }
    i=0;
    j=0;
    while(j<n){
               scanf("%lf",&y[j][i]);
               j++;
               }


    for(i=0;i<n;i++){
                     printf("x[%d]=%d",i,x[i]);
                     }
                 i=0;j=0;
    printf("\n");
     while(j<n){
                        printf("y[%d][%d]=%lf",j,i,y[j][i]);
                          j++;

                          }  
    printf("\n");
                     k=0; 
                     m=1;    
      for(i=1;i<n;i++){
                        for(j=0;j<n-i;j++){
                                            y[j][i]=((y[j+1][i-1]-y[j][i-1])/(x[k+m]-x[k]));
                                            k++;

                                            }
                                            k=0;
                                            m=1+m;
                                            }
      printf("\n");

         for(i=0;i<n-1;i++){
                            for(j=0;j<n-i;j++){
                                               printf("y[%d][%d]=%lf",j,i,y[j][i]);
                                               printf("\n");
                                               }
                                               }

                                               getch();
                                               }         
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.