#include<iostream.h> #include<conio.h> #include<math.h> double fact(double k) { if(k==0||k==1) return 1; else return k*fact(k-1); } double coss(float x,int N) { double sum=0,sign=1,term=0; sum+=1; int i; for(i=2;i<=N;i+2) {sign*=-1; term=(sign*pow(x,i))/i; sum+=term; } return sum; } void main() {double num,n; cout<<"Enter the value and accuracy"; cin>>num>>n; cout<<"value is"<<coss(num,n); getch(); }

I dont know but this program hangs after taking the input, are the calculations very large ? I think they should be in double's range.

Help is appreciated