Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
120465-11.1-3E
//gcc 7.4.0 #include <stdio.h> #include<stdlib.h> int experiment(void) { float sim; int j,nDeclined; nDeclined=0; int event=0; for(j=0;j<300;j++) { sim=rand()/((float) RAND_MAX); if(sim<0.35) { nDeclined++; } if(nDeclined>100) { event=1; return event; } } return event; } int main() { int i,n,counter; time_t t; srand((unsigned)time(&t)); for(n=10;n<10000000;n*=10) { counter=0; for(i=0;i<n;i++) { counter=counter+experiment(); } printf("For n=%d\t P(A)=%.5f\n",n,counter/((float) n)); } return(0); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Project v0.07
Array Practice
Project 4 v1.1
scanf and integer manipulation
c program for hollow rhombus
150114_MatrizSumaPerimetro
Volume of a square pyramid With functions
Function practice
final advice
purple ghost red orange blue skulls
stackse - search stackoverflow differently
Please log in to post a comment.