N=input('enter no of dats');
r=4;
c=0;
for i=1:N
x=r*rand(1);
y=r*rand(1);
if((x^2+y^2)<=r^2)
c=c+1;
end;
end;
n=c;
pi=(4*n)/N
r=4;
c=0;
for i=1:N
x=r*rand(1);
y=r*rand(1);
if((x^2+y^2)<=r^2)
c=c+1;
end;
end;
n=c;
pi=(4*n)/N
Programs Based on c/c++/java
No comments:
Post a Comment