Write a C++ program to calculate time dilation (t) in motion, when the speed of the moving objects (v) is given by the user. The given below is the equation to calculate the time dilation.
t = t0 /squreroot 1-v2/c2
v = speed of the moving object, c = 15000 ms-1(speed of light), and t0 = 75 s (time in observers own frame of reference)
· User may insert a speed of the moving objects (v) above 60 ms-1 and below 75 ms-1 as the highest Speed.
· Consider the speed of light (c) as a constant value.
· Then the program should calculate the time dilation (t) for each speed of the moving object until the speed becomes 59 ms-1.
· Use the necessary header files to do the calculation.
output
Enter the speed of the object :67
67 8.66034
66 8.66034
65 8.66034
64 8.66033
63 8.66033
62 8.66033
61 8.66033
60 8.66032
#include <iostream>
#include <math.h>
using namespace std;
int main(){
float t0 = 75, t, v, c = 15000;
cout<<"Input the speed of the object: ";
cin>>v;
while(v < 60 || v > 75){
cout<<"Speed is beyond acceptable limits. Enter speed again: ";
cin>>v;
}
while(v >= 60){
t = t0 / pow(1 - pow(v, 2) / pow(c, 2), 0.5);
cout<<v<<" "<<t<<endl;
v--;
}
return 0;
}
Comments
Leave a comment