Write four C subroutines, the first computes the sine of a number provided as in
ID: 3935407 • Letter: W
Question
Write four C subroutines, the first computes the sine of a number provided as input, the second computes the squareroot of the number provided, the third computes the square of the number and the fourth computes the sum of the square, squareroot and the sine values returned by these first three functions Create a main program which will call and use all four subroutines. Create a makefile to provide the ability to individually make each of these subprograms separately (e.g. make sum, make square, make squareroot, make sine, etc.) or to make them all using the call make all. Augment your Makefile from 3 to include a make clean that removes all of the object files in the directory of the makefile related to your builds above.Explanation / Answer
#include <stdio.h>
#include <math.h>
#define PI 3.14159265 // to convert radians to degree in sin value calcultaions.
double makesum(double a,double b);
{
return a+b;
}
double makesquare(double a);
{
return a*a;
}
double makesuareroot(double a);
{
return sqrt(a);
}
double makesin(double a);
{
return getsin(a*val);;
}
int main ()
{
double x, y,ret, sinval,sum,square,squareroot;
x = 45.0;
y=65.0;
val = PI / 180;
sinvlaue = makesin(x*val);
sum= makesum(x,y);
square= makesqure(x,y);
squareroot = makesqureroot(x,y);
printf("The sine of %lf is %lf degrees", x, sinvlaue );
printf("The sum of %lf and %lf is %lf degrees", x,y, sum);
printf("The square of %lf and %lf is %lf degrees", x, square);
printf("The squareroot of %lf and %lf is %lf degrees", x,squareroot);
return(0);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.