# C programming basics

This is a discussion on C programming basics within the C Programming forums, part of the General Programming Boards category; I wrote code for sinx But it is showing output as INF Why INF?? what's wrong with code .... plz ...

1. ## C programming basics

I wrote code for sinx

But it is showing output as INF

Why INF?? what's wrong with code ....
plz help

Code:
```#include<stdio.h>
#include<math.h>
int main()
{
float x,t=0,sum;
int i,n,sig=1;
printf("Input X,N");
scanf("%f %d",&x,&n);
x*=(3.14/180);
sum=x;
for(i=0;i<n;i++)
{
sig*=-1;
t=(sig*x*x)/(2*i*(2*i+1));
sum+=t;
}
printf("SIN(X) = %f\n",sum);
return 0;
}```

2. The first time throught the loop, i is zero ... and the calculation for t implies a division by zero, which yields INFINITY

Code:
`t=(sig*x*x)/(2*i*(2*i+1)); // divide by zero`

3. Originally Posted by qny
The first time throught the loop, i is zero ... and the calculation for t implies a division by zero, which yields INFINITY

Code:
`t=(sig*x*x)/(2*i*(2*i+1)); // divide by zero`
Thank you