Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- int main()
- {
- int j,count=0,limit,i=0,head,tail;
- float y,answer,h=2.5;
- printf("enter the limit amount");
- scanf("%d",&limit);
- //drawing head in head tails either 3 6 or 9 times
- while(i<=limit)
- {
- i++;
- head=0;
- tail=0;
- //toss 10 times
- for(j=0;j<10;j++)
- {
- //random number generated
- y=(float)((rand()% 65535)/65535.0f)*10;
- printf("%f\n",y);
- //head if y <2.5
- if (y<h)
- {
- head=head+1;
- }
- else
- {
- tail=tail+1;
- }
- }
- //check prpob
- if ((head==3) || (head==6) || (head==9))
- {
- count=count+1;
- }
- }
- answer=(float)count/limit;
- printf("the limit is= %d \n and the probability is = %f",limit,answer);
- return 0;
- }
Add Comment
Please, Sign In to add comment