Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Sunday, April 4, 2010

To find and print Correlation of coefficient.

The Blind SideWrite a program in C to input 5 integer values of x & y and to calculate and print the coefficient of correlation between x & y.



#include<stdio.h>
#include<conio.h>
#include<math.h>
void main( )
{
int x, y, i;

float sx=0, sy=0, sxx=0, syy=0, sxy=0, a, b, c, r;
clrscr( );
for(i=1; i<=5; i++)
{
printf("Input values of x and y pairwise\n");
scanf("%d %d", &x, &y);
sx = sx + x;
sy = sy + y;
sxx = sxx + x * x;
syy = syy + y * y;
}
a = sxy - (sx * sy) / 5;
b = sqrt(sxx - (sx * sx) / 5 );
c = sqrt(syy - (sy * sy) / 5 );
r = a / (b *c);
printf("The correlation coefficient = %f\n", r);

}

Related Posts by Categories



0 comments:

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP