fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. double estimate_pi(long long n){
  6. double randomx, randomy, equation, pi;
  7. long long i, incircle = 0;
  8.  
  9. for(i = 0; i < n; i++){
  10. randomx = (double)(rand() % (1+1-0) + 0);
  11. randomy = (double)(rand() % (1+1-0) + 0);
  12.  
  13. printf("%d %d\n", randomx, randomy)
  14.  
  15. equation = randomx * randomx + randomy * randomy;
  16.  
  17. if(equation <= 1){
  18. incircle++;
  19. }
  20. }
  21.  
  22. pi = (long double)4 * (long double)incircle / (long double)n;
  23.  
  24. return pi;
  25. }
  26.  
  27. int main()
  28. {
  29. printf("%d\n", estimate_pi(100));
  30. return 0;
  31.  
  32. }
Compilation error #stdin compilation error #stdout 0s 15232KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘double estimate_pi(long long int)’:
prog.cpp:15:9: error: expected ‘;’ before ‘equation’
         equation = randomx * randomx + randomy * randomy;
         ^~~~~~~~
stdout
Standard output is empty