Chapter 7 Challenge - Sine of 1 radian

Code:

[code]
/* Use the math library!
Add code to main.c that displays the sine of 1 radian.
Show the number rounded to three decimal points. It should be 0.841.
The sine function is declared like this: double sin(double x);
*/

#include <stdio.h>
#include <math.h>

double calculatedSin(double x){

double radiantOfx = sin(x);
return radiantOfx;

}

int main(int argc, const char * argv[]) {

double x = 1.0;
printf("Sine of 1 radian is %0.3f \n",calculatedSin(x) );

return 0;

}[/code]

Console Output:

[quote]Sine of 1 radian is 0.841
Program ended with exit code: 0[/quote]

This does the job as well:

int main(int argc, const char * argv[]) { double x = sin(1); printf("The sine of 1 radian is %.3f\n", x); }