<code><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string"><stdio.h></span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string"><math.h></span></span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>
</span>{
<span class="hljs-keyword">double</span> x;
<span class="hljs-keyword">double</span> result;
x = <span class="hljs-number">2.3</span>;
result = <span class="hljs-built_in">sin</span>(x);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"sin(%.2lf) = %.2lf\n"</span>, x, result);
x = <span class="hljs-number">-2.3</span>;
result = <span class="hljs-built_in">sin</span>(x);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"sin(%.2lf) = %.2lf\n"</span>, x, result);
x = <span class="hljs-number">0</span>;
result = <span class="hljs-built_in">sin</span>(x);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"sin(%.2lf) = %.2lf\n"</span>, x, result);
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}</code>
Output
<samp>sin(2.30) = 0.75 sin(-2.30) = -0.75 sin(0.00) = 0.00</samp>
The output of the provided code will be:
<span class="hljs-built_in">sin</span>(<span class="hljs-number">2.30</span>) = <span class="hljs-number">0.75</span>
<span class="hljs-built_in">sin</span>(-<span class="hljs-number">2.30</span>) = -<span class="hljs-number">0.75</span>
<span class="hljs-built_in">sin</span>(<span class="hljs-number">0.00</span>) = <span class="hljs-number">0.00</span>
This output corresponds to the results of calculating the sine of the given angles:
- The sine of 2.3 radians is approximately 0.75.
- The sine of -2.3 radians is approximately -0.75.
- The sine of 0 radians is exactly 0.
The printf statements in the code use the format "sin(%.2lf) = %.2lf\n" to display the values with two decimal places. The first %lf specifier is used to print the angle x, and the second %lf specifier is used to print the calculated sine result. The \n represents a newline character, which adds a line break after each output line.
