I need some help getting this factorial to work. I don't think I'm getting this to work right since only the first 2 work in the series. I probably could write a function to fix this but there has to be a way to loop it instead. This is what I have so far.
#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
double a,b,c,d,e,f,g,x,sum=0,fact=1;
cout << "This finds probability at the airport." << endl;
cout << " ";
cout << endl << endl;
cout << "Enter the number of plane arrivals per minute (lamda). " << endl;
cin >> a;
cout << "Average Arrival's/min # Arrival's/min Probability\n"
<< "--------------------- --------------- ------------" << endl;
cout << setiosflags(ios::fixed)
<< setiosflags(ios::showpoint)
<< setprecision(4);
for (x = 1.0; x <= 10.0; x = x + 1.0) // three control expressions of the loop
{
b=pow(a,x);
c=pow(2.71828, -a);
d=b*c;
fact*=x;
e=d/fact;
cout << setw(21) << a << setw(15) << x << setiosflags(ios::fixed)<< setiosflags(ios::showpoint)
<< setprecision(4)<< setw(12) << e << endl;
}
return 0;
}