Gauss Jordon Forward Interpolation Formula Using C programming


Gauss Jordon Forward Interpolation Formula Using C programming :



#include<stdio.h>
#include<conio.h>
int main()
{
    int n,i,j,k;
    printf("Enter the Number of Equations");
    scanf("%d",&n);
    float a[n][2*n],c;
    for(i=1;i<=n;i++)
    {
         for(j=1;j<=2*n;j++)
         {
             if(j<=n)
             {
                 printf("Enter the x[%d][%d] : ",i,j);
                 scanf("%f",&a[i][j]);
             }
                 else if(j>n&&(j-n==i))
                    a[i][j]=1;
                 else
                    a[i][j]=0;

         }
    }
    for(j=1;j<=n;j++)
    {
        for(i=1;i<=n;i++)
        {
            if(i!=j)
            {
                c=a[i][j]/a[j][j];
                {
                    for(k=1;k<=2*n;k++)
                    {
                        a[i][k]=a[i][k]-c*a[j][k];
                    }
                }
            }
        }
    }
     for(i=1;i<=n;i++)
    {
        for(j=1;j<=2*n;j++)
        {
            a[i][j]=a[i][j]/a[i][i];
            if(j>n)
                printf("%f\t",a[i][j]);
        }
        printf("\n");
    }
    return 0;

}

Comments

Popular posts from this blog

Newton Backward Interpolation Formula