#include<math.h>
#include<iostream>
using namespace std;
float computing_cos(float x) {
float number = 0.0001, t, deno, cos_X, cos_val;
x = x * (3.142 / 180.0);
t = 1;
cos_X = t;
cos_val = cos(x);
int n = 1;
do {
deno = 2 * n * (2 * n - 1);
t = -t * x * x / deno;
cos_X = cos_X + t;
n = n + 1;
} while (number <= fabs(cos_val - cos_X));
return cos_X;
}
int main(){
float n =60;
double pi = 3.14286;
cout<<"Enter the angle \n";
int angle;
cin>>angle;
float l = 1.75;
for(int i=angle; i>=20; i--){
double T = 2 * pi * (sqrt((l * computing_cos(i)) / 9.8));
cout<<"For angle "<< i <<" period of a conical pendulum is: "<<T<<endl;
}
}
Comments
Leave a comment