To find and print the regression coefficient.
The Twilight Saga: New Moon (Two-Disc Special Edition)
Write a program in C to input 25 pair of x & y and calculate and print the regression coefficient (b).
Write a program in C to input 25 pair of x & y and calculate and print the regression coefficient (b).
#include< #include< #include< #define N 25 void main( ) { int i, x, y; float sx=0, sy=0, sxy=0, syy=0, a, b, c; clrscr( ); for(i=1; i<=N; i++) { printf("Input values of x & y pairwise\n"); scanf("%d %d", &x, &y); sx = sx + x; sy = sy + y; sxy = sxy + x * y; syy = syy + y * y; } a = N*sxy - sx*sy; c = N*syy - sy*sy; b = a/c; printf("\n The regression coefficient is %f\n", b); } |
---|
0 comments:
Post a Comment