Hi all people
I've written program below for a physics problem.
#include <iostream>
#include <conio.h>
#include <math.h>
#define g 9.8342998109761958158459616185564
using namespace std;
long double theta(unsigned long int n,unsigned long int N){
return (M_PI/2)-n*(M_PI/(2*N));
}
long double V(unsigned long int n,unsigned long int N,unsigned long int h){
if(n!=0){
long double r=4*g*(h*M_PI/(4*N));
return sqrt(r*sin(theta(n,N))+pow(V(n-1,N,h),2));
}
else return 0;
}
int main(){
unsigned long int N,h;
cout<<"Enter the number of segments:";
cin>>N;
cout<<"Enter the radius of the curve:";
cin>>h;
cout<<"\nTerminal velocity = "<<V(N,N,h)<<"\n";
getch();
return 0;
}
As you've already understood,the higher the value of N,the higher accuracy for the answer.But when I enter Ns more than 21711 for every h I give no answer.I wanna know how can I do sth that I get an ansewr for higher Ns too.
thanks