#include <iostream.h>
#include <math.h>
#include <conio.h>
#include <fstream.h>
#include <iomanip.h>
#include <stdlib.h>
int main()
{
const float PI=3.1415926536;
int cnt,fct,z;
float x,y,fnl;
char f1Name[40]; //filename
ofstream f1;
cout<<"enter the file name for writing:";
cin>>f1Name;
f1.open(f1Name);
if(f1.fail())
{
cout<<"the file cannot be opened";
exit(1);
}else
cout<<"file opened successfully.";
for(z=0;z<=360;z+=5)
{
if(z%180!=0) // i wrote that due to a false calculation as a bypass
{
x=z;
x*=(PI/180);
y=x;
fct=1;
for(cnt=1;cnt<100;cnt++)
{
fnl+=y;
fct+=1;
y/=fct;
fct+=1;
y/=fct;
y*=(-1*pow(x,2));
}
cout<<x<<" "<<"sin"<<z<<"="<<fnl<<endl;
f1<<x<<" "<<z<<" "<<fnl<<endl;
fnl=0;
}else
{
cout<<x<<" "<<"sin"<<z<<"=0"<<endl;
f1<<x<<" "<<z<<" "<<"0"<<endl;
}
}
f1.close();
cout<<"file proccess ended.";
getch();
return 0;
}
all seems fine, but here is the results of the file: (exe results are the same, the problem is numbers in calculation i think,and dont know exactly where it is.)
well, i bypassed it and it appears there is nothing wrong with calculation, there is something wrong with something else, i guess. :/ and sorry about my english :P