#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int n,i,j;
float a,la,b,x[10],y[10],sx,sly,sxly,sx2;
printf("Saroj Rana\nRoll:37\tSem:3rd\n");
printf("Enter number of points:");
scanf("%d",&n);
for(i=0;i<n;i++){
printf("Enter value for x and y at i=%d\n",i);
scanf("%f%f",&x[i],&y[i]);
}
sx=0;
sly=0;
sxly=0;
sx2=0;
for(i=0;i<n;i++){
sx=sx+x[i];
sly=sly+log(y[i]);
sxly=sxly+x[i]*log(y[i]);
sx2=sx2+x[i]*x[i];
}
b=((n*sxly)-(sx*sly))/((n*sx2)-(sx*sx));
la=(sly/n)-(b*sx/n);
a=exp(la);
printf("Equation of type y=a*e^(bx)\n");
printf("Straight line equation: y=%f*e^(%fx)",a,b);
getch();
return 0;
}
No comments:
Post a Comment