Hi. I have written a bit of code to sum the components of vectors F=ai+bj+ck and compiled the code with Devc++4. The compiler keeps giving me parse error at the end of input. It's not the first time I've seen this, but I can't remember how to fix it. Thanks a bunch...
Code:
#include<iostream.h>
#include<math.h>
#include <stdlib.h>
const int size=100;
int main(){
double F,theta,phi;
double f1[size],theta1[size],phi1[size];
double fx[size],fy[size],fz[size];
double ratio,fxs,fys,fzs; int n,i;
ratio=3.14159/180;
cout<<"type in the number of vectors that you want to add up"<<endl;
cin>>n;
if(n<=size&&(n>1))
{for(i=0;i<n;i++)
{cout<<"type in f1, theta1 and phi1 for all vectors"<<endl;
cin>>f1[i]>>theta1[i]>>phi1[i];
cout<<"f1[i]="<<f1[i]<<" theta1[i]="<<theta1[i]<<" phi1[i]="<<phi1[i]<<endl;
fx[i]=f1[i]*sin(theta1[i]*ratio)*cos(phi1[i]*ratio);
fy[i]=f1[i]*sin(theta1[i]*ratio)*sin(phi1[i]*ratio);
fz[i]=f1[i]*cos(theta1[i]*ratio);
fxs=fxs+fx[i];
fys=fys+fy[i];
fzs=fzs+fz[i];}
//Calculate F, theta and phi
double fxy;
F=sqrt(fxs*fxs+fys*fys+fzs*fzs);
fxy=sqrt(fxs*fxs+fys*fys);
if(F==0.0)
{cout<<"magnitude of F is zero"<<endl;}
return(1);
theta=acos(fzs/F)/ratio;
if(fxs<0.0)
{phi=90.0;
if(fys<0.0)
{phi=-90.0;}}
else
{phi=atan(fys/(fxs*ratio));
if(fxs<0.0)
{phi=phi+180;}}
cout<<"sumof vectors"<<endl;
cout<<"F="<<F<<" theta="<<theta<<" phi="<<phi<<endl;
system("PAUSE");
return 0;}