Hey everyone. I'm new to C programming. I'm working on a little code of my own right now and it compiles fine, but after the user inserts some data and presses enter, this error pops up. Here's the code:
Once you run it, the segmentation error comes up after the combined mass is entered (Mtot). Any help on fixing this problem would be appreciated.
double G, T, Mtot, R, v, B, A, C, Pi, distance;
int main (void)
G = 6.67e-11;
Pi = 3.14159;
printf("Enter the combined mass of the systems (kg):");
printf("Enter distance between galaxies (kpc):");
printf("Enter the relative velocity of the approaching galaxy (km/s):");
C = ((pow(v,2))/2.0) - (G*Mtot)/R;
T = (2.0*Pi*v*(pow(R,2)))/(C*G*Mtot);
printf("\nwhen T = %d years,",T);
printf(" then the other galaxy is %f kpc away",R);
Oh, and I've been using Cygwin, if that's of any consequence. It's the program we're given for the class I'm in.