I have developed a program that is supposed to a value between -1 to 1 with decimal point.

Every thing seem to work fine only that it prints 0 for all values.

Problem seems to be with this line

printf("\n Correction Coffecient = %f", (numerator/denominator));

Thanks

Every thing seem to work fine only that it prints 0 for all values.

Problem seems to be with this line

printf("\n Correction Coffecient = %f", (numerator/denominator));

Thanks

```
#include <stdio.h>
#include <conio.h>
#include <math.h>
main()
{
int odds[20], i,j,cn,n, prn[20];
long sumxy, sumx, sumy, sumxsqr, sumysqr, denominator, numerator;
float cc;
unsigned long int d1,d2;
cn=0;
i=2;
/* start at 2 for prime numbers becauase 1 is not */
/*======== to get the prime numbers ========*/
while (cn<20)
{
for(j=2; j<=i; j++)
{
if (i % j==0)
{
if (j==i)
{
prn[cn] = i;
cn++ ;
}
else{
break;
}
}
}
i++;
}
clrscr();
printf("Prime numbers are below");
printf("\n=======================");
for (n=0; n<20; n++)
{
printf("\nPrime number: %d ie = %d", n+1, prn[n]);
}
/* odd numbers */
cn=0;
i=1;
printf("\n\nOdd numbers below");
printf("\n==================");
while (cn<20)
{
for(j=i; j<=i; j++)
{
if(j%2==1)
{
printf("\nOdd number %d is %d",cn+1,j);
odds[cn]=j;
cn++;
}
}
i++;
}
/*getting the correlation coefficient*/
sumxy=0;sumx=0; sumy=0; sumxsqr=0; sumysqr=0;numerator=0;denominator=0;d1=0;d2=0;
for(i=0;i<20;i++)
{
sumxy+=(prn[i]*odds[i]);
sumx+=prn[i];
sumy+=odds[i];
sumxsqr+=(prn[i]*prn[i]);
sumysqr+=(odds[i]*odds[i]);
}
numerator=20*sumxy-(sumx*sumy);
denominator=sqrt(20*sumxsqr-(sumx*sumx))*sqrt(20*sumysqr-(sumy*sumy));
cc=20/30; /* (numerator/denominator)*100;*/
printf("\n sumxy =%d",sumxy);
printf("\n sun x = %d", sumx);
printf("\n sum y = %d", sumy);
printf("\n sum x squared = %d", sumxsqr);
printf("\n sum y squared = %d", sumysqr);
printf("\n Numerator = %ld", numerator);
printf("\n Denominator = %ld", denominator);
printf("\n Correction Coffecient = %f", (numerator/denominator));
getch();
```

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.