4 votes 4 votes main() { int c=0,x,i,y; for(i=0;i<N;i++) { x=random();y=random(); if((x2+y2)<1) c++; } print(c); } random() is a function which returns random number between $0$ or $1$, $N$ is a large number what is the output of the program? Programming in C programming-in-c iiith-pgee + – dragonball asked May 2, 2017 retagged Jun 4, 2017 by Arjun dragonball 2.3k views answer comment Share Follow See all 24 Comments See all 24 24 Comments reply Show 21 previous comments Sushant Gokhale commented May 3, 2017 reply Follow Share @Dhruv. I accept my mistake :) I applied wrong concept. 0 votes 0 votes srestha commented May 3, 2017 reply Follow Share @Debashish I am in doubt how floating point could be applied here? U mean decimal value? 0 votes 0 votes A_i_$_h commented Jun 19, 2017 reply Follow Share how are u taking the probability of pi/4, can u please explain in a more simple way 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes This is monte carlo method to estimate value of pi. Value of c : N*π/4 For reference to monte carlo method: http://www.dartmouth.edu/~rc/classes/soft_dev/C_simple_ex.html Enyt_S answered Apr 22, 2019 Enyt_S comment Share Follow See all 0 reply Please log in or register to add a comment.