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,025 views
2 answers 260 views
2 answers 242 views
2 answers 273 views
2 answers 265 views
2 answers 265 views
1 answer 218 views
...