How to calculate PI value with acos() function in C

2 Answers

0 votes
#include <stdio.h>     
#include <math.h>
  
int main()
{   
    double pi = acos(-1);
     
    printf("pi = %lf\n", pi);
     
    return 0;
}

  
/*
run:
    
pi = 3.141593
 
*/

 



answered Mar 30, 2016 by avibootz
edited Oct 4, 2024 by avibootz
0 votes
#include <stdio.h>     
#include <math.h>
  
int main()
{   
    double pi = 2 * acos(0.0); 
     
    printf("pi = %lf\n", pi);
     
    return 0;
}


  
/*
run:
    
pi = 3.141593
 
*/

 



answered Oct 4, 2024 by avibootz

Related questions

2 answers 1,024 views
2 answers 258 views
2 answers 239 views
2 answers 271 views
2 answers 263 views
2 answers 262 views
1 answer 216 views
...