Advertisement
Guest User

yes

a guest
Apr 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include<stdio.h>
  2. main()
  3. {
  4. float x[100],y[100],a,s=1,t=1,k=0;
  5. int n,i,j,d=1;
  6. printf("\n\n Enter the number of the terms of the table: ");
  7. scanf("%d",&n);
  8. printf("\n\n Enter the respective values of the variables x and y: \n");
  9. for(i=0; i<n; i++)
  10. {
  11. scanf ("%f",&x[i]);
  12. scanf("%f",&y[i]);
  13. }
  14. printf("\n\n The table you entered is as follows :\n\n");
  15. for(i=0; i<n; i++)
  16. {
  17. printf("%0.3f\t%0.3f",x[i],y[i]);
  18. printf("\n");
  19. }
  20. while(d==1)
  21. {
  22. printf(" \n\n\n Enter the value of the x to find the respective value of y\n\n\n");
  23. scanf("%f",&a);
  24. for(i=0; i<n; i++)
  25. {
  26. s=1;
  27. t=1;
  28. for(j=0; j<n; j++)
  29. {
  30. if(j!=i)
  31. {
  32. s=s*(a-x[j]);
  33. t=t*(x[i]-x[j]);
  34. }
  35. }
  36. k=k+((s/t)*y[i]);
  37. }
  38. printf("\n\n The respective value of the variable y is: %f",k);
  39. printf("\n\n Do you want to continue?\n\n Press 1 to continue and any other key to exit");
  40. scanf("%d",&d);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement