Hi there I just wondered if someone could offer any advice as to how to rephrase or repair my calculations in the following code. I need to use a user inputted velocity (float 'v') and a user inputted duration (float 'tO') in the formula t=tO/square root of (1-(c^2/v^2)) But for some reason I'm having trouble. If anyone can help I'd really appreciate it (I did try to use code tags but may not have done so successfully):
Code:
#include <stdio.h>
#include <math.h>
int main()
{
int c=299792458,sqrt=0.5;
char again;
float t=0,tO=0,v=0,calc_a=0,calc_b=0,calc_c=0,ans=0;
do
{
printf ("Hello user this calculator can calculate time dialation if you enter your velocity and journey duration.\n");
printf ("Please enter your velocity in m/s: ");
scanf ("%f", &v);
if (v>=299792458)
{
}
if (v<=0)
{
}
else
printf ("Please enter the duration of your journey to the nearest whole year: ");
scanf ("%f", &tO);
if (tO<=0)
{
}
else
calc_a = (1-((c*c)/(v*v))); // problem area //
calc_b = (pow(calc_a,sqrt));
t = (tO/calc_b);
calc_c = (t-tO);
printf ("Therefore the time observed at the origin %g - the journey duration %g gives us the time contraction\n", t,tO);
printf ("Which equals %g years of time dialation",c);
getchar();
printf ("Do you want to do another calculation?\n");
printf ("If so press the 'y' key, otherwise press any other key: ");
scanf ("%c",&again);
} while (again == 'y');
getchar();
printf ("Thank you for using my program!\n");
printf ("Press enter to close the program\n");
getchar();
return 0;
}