0

I have to write a program that will evaluate the equation 2 ^ − √3+ x/2, where 1 <= x <= 180 [No checking needed]. Here there are problem's Image

Those are some sample output:

Input: 30 Output: 1.810066

Input 120 Output 0.778151

Input 180 Output 3.954243

This is what I've tried so far, but it does not match the output wanted

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

int main() {
    double x;
    double result;
    scanf("%lf", &x);

    result = 2 * pow(cos(x),2) - sqrt(3) * sin(x) + sin(x / 2);

    printf("%.8lf\n", result);

    return 0;
}
Atik
  • 3
  • 4
  • For the sample inputs, what *is* the actual output? – Some programmer dude May 29 '23 at 08:13
  • 7
    As a proable hint about the problem: The [`sin`](https://en.cppreference.com/w/c/numeric/math/sin) and [`cos`](https://en.cppreference.com/w/c/numeric/math/cos) function expects their inputs to be angles in *radians*, not degrees. – Some programmer dude May 29 '23 at 08:15
  • It's like any calculator. The first thing you do when picking one up is to scratch your head to figure out if it uses radians or degrees, before you use any trig functions. Except C has no option to conveniently switch, so you have to calculate degrees manually. – Lundin May 29 '23 at 10:42

0 Answers0