this is fucking trash, go back to scripting in pyshit, c isnt for retards that dont even know how pointers work or for video games or retarded man children that still watch chinese cartoons and play with childrens toys and """""VIDYAhueheuehue""""
go pick up a handicap accessible language like pyshit or c++ for your vidya you mentally disable man child
# include <stdio.h>
# include <stdlib.h>
float mass,vel,accel,mom,vi,vf,t,L,W,m,r,I,ai,af,a;
float (*func)();
float L() { return mass*0.5*(vel*vel); }
float O() { return mass*vel; }
float S() { return (vf-vi)/t; }
float E() { return (vi*t) + ((0.5*a)*(t*t)); }
float R()
{ static int i = -1;
switch (i++)
{ case 0: W=(af-ai)/t;
return W;
case 1: L=(m*r*W);
return L;
case 2: i=0;
return (L/W);
}
}
void main()
{
int select = 0;
while ( select >= 0 && select < 5 )
{ printf("\n\n Choose Solver: 1: Kinetic Energy, 2: Momentum, 3: Acceleration, \n 4: Displacement, 5: Rotational Inertia, 0: Exit\n");
scanf("%d", &select );
select--;
void *vars[5][8] = { { (int*)2, &mass, &vel },
{ (int*)2, &mass, &vel },
{ (int*)3, &vi, &vf, &t },
{ (int*)3, &vi, &a, &t },
{ (int*)5, &m, &r, &ai ,&af, &t} };
char out[5][8][128] = { {"Kinetic Energy is %f Newtons", "Input mass kg\n", "Input velocity m/s\n"},
{"Momentum is %f kg-m/s", "Input mass kg\n", "Input velocity m/s\n"},
{"Acceleration is %f meters per second, per second", "Input initial velocity m/s\n",
"Input final velocity m/s\n", "Over what time period? (seconds)\n"},
{"Distance moved in one dimension is %f meters", "Input initial velocity m/s\n",
"Input acceleration ms/s\n", "Input Time (seconds)\n" },
{"Angular velocity is %f \n\nAngular momentum is %f \n\nRotational inertia is %f\n",
"Input mass kg\n", "Input initial angle\n", "Input final angle\n",
"Input radius (meters)\n", "Input time in seconds\n"} };
void *funcs[5] = { L,O,S,E,R };
for ( int i=1; i<=*(int*)(vars[select]); i++ ) [Expand Post]
{ printf( "%s", out[select][i] );
scanf( "%f", vars[select][i] );
}
func = funcs[select];
printf( **(out + select), func(),func(),func() );
}
}