How to compute cosine in C

3 Answers

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

int main(void)
{
    double d = acos(-1);

    printf("%lf", d);
}





/*
run:

3.141593

*/

 



answered Jan 27, 2023 by avibootz
0 votes
#include <stdio.h>
#include <math.h>

int main(void)
{
    double f = cosf(1);

    printf("%f", f);
}





/*
run:

0.540302

*/

 



answered Jan 27, 2023 by avibootz
0 votes
#include <stdio.h>
#include <math.h>

int main(void)
{
    long double ld = cosl(0.0);

    printf("%Lf", ld);
}





/*
run:

1.000000

*/

 



answered Jan 27, 2023 by avibootz

Related questions

3 answers 165 views
165 views asked Jan 28, 2023 by avibootz
3 answers 163 views
163 views asked Jan 25, 2023 by avibootz
3 answers 135 views
135 views asked Jan 25, 2023 by avibootz
1 answer 113 views
1 answer 183 views
1 answer 193 views
1 answer 208 views
...