My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
Advertisements
|
C++ Program for probability 1
Posted Date: 23 Mar 2008 Resource Type: Articles/Knowledge Sharing Category: Computer & Technology
|
Posted By: ashish singh Member Level: Diamond Rating: Points: 3
|
|
|
|
//Program for (probability 1)
#include #include #include float nCr(int n,int r); float fact(int n) ; void main() { textcolor(YELLOW); clrscr(); int r,b,w,t,r1,b1,w1,t1;float prob,p1,p2,p3,sam_s; cout<<"enter the number of red balls : "; cin>>r; cout<<"enter the number of blue balls : "; cin>>b; cout<<"enter the number of white balls : "; cin>>w; t=r+b+w; cout<<"enter the number of red ball drawn : "; cin>>r1; cout<<"enter the number of blue ball drawn : "; cin>>b1; cout<<"enter the number of white ball drawn : "; cin>>w1; t1=r1+b1+w1; sam_s=nCr(t,t1); p1=nCr(r,r1);p2=nCr(b,b1);p3=nCr(w,w1); prob=(p1*p2*p3)/sam_s; cout<<"\nthe probability of drawing "< white balls is : "<delay(100); textcolor(RED); cout<<"\n\n\a"; cprintf("PROGRAM DESIGNED BY:PRASHANT KUMAR SINGH"); cout<<"\n\n"; cprintf("BRANCH : ECE / 3rd semester / roll 194/06 ");
getch(); }
float fact(int n) {float fn=1; if(n==0) return(1); else { for(int i=1;i<=n;i++) fn*=i; return(fn); } }
float nCr(int n,int r) { float C=fact(n)/(fact(r)*fact(n-r)); return(C); }
output:
enter the number of red balls : 3 enter the number of blue balls : 7 enter the number of white balls : 6 enter the number of red ball drawn : 0 enter the number of blue ball drawn : 1 enter the number of white ball drawn : 1
the probability of drawing 0 red 1 blue 1 white balls is : 0.35
|
Responses
|
| Author: Girish Patil 02 Jun 2008 | Member Level: Diamond Points : 2 | good...keep going...
|
|
|