It gives no error but the switch statement always goes to the default case. I didn't paste the functions for the sake of concision.
I was advised to break my programs into subroutines, but is structured programming always better? Even if it takes more line of code and longer to execute?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef M_PI
#define PI M_PI
#else
#define PI 3.14159265358979323846264338327950288420
#endif // M_PI
int getData(int op);
float degreesToRadians(float angle);
float sine(float degrees);
float cosine(float degrees);
float tangent(float degrees);
float sineInverse(float degrees);
float cosineInverse(float degrees);
float tangentInverse(float degrees);
int main(void)
{
float degrees;
int op;
getData(op);
printf("Enter the angle in degrees: ");
scanf("%f", °rees);
degreesToRadians(degrees);
switch(op)
{
case 1:
sine(degrees);
break;
case 2:
cosine(degrees);
break;
case 3:
tangent(degrees);
break;
case 4:
sineInverse(degrees);
break;
case 5:
cosineInverse(degrees);
break;
case 6:
tangentInverse(degrees);
break;
default:
printf("You entered an invalid option!");
break;
}
return 0;
}