I am trying to automate my program for Simpsons rule. Finally got it running thx to here, so now I'm trying to have it ask the user for all the variables on run. Everything is good except for inputting the function to integrate itself. After entering the function i get

Enter your function: x

Enter your function: Enter your function: Enter your function: Enter your function: Enter your function: Enter your function: Enter your function: Enter your function: -1.85119262699e+062

Press any key to continue . . .

```
// hw2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;
double f_int(double x);
double I_simpson(double a, double b, int n);
int main()
{
double a;
double b;
double n;
double f;
cout << "Enter lower limit: ";
cin >> a;
cout << "Enter upper limit: ";
cin >> b;
cout << "Enter number of partitions: ";
cin >> n;
double d = I_simpson(a, b, n);
std::cout << std::setprecision (12) << d << std::endl;
system ("PAUSE");
return 0;
}
double f_int(double x)
{
double c;
cout << "Enter your function: ";
cin >> c;
return c;
}
double I_simpson(double a, double b, int n)
{
double h = (b-a)/n;
double I_simpson = 0;
int i;
I_simpson = (f_int(a)/6) + (f_int(b)/6);
for ( i=1 ; i<=(n-1) ; i++)
{
I_simpson = I_simpson + (f_int(a + (i * h))/3);
}
for (i=1 ; i<=n ; i++)
{
I_simpson = I_simpson + ((2*f_int(a + (i - (1.0/2))*h))/3);
}
I_simpson *= h;
return I_simpson;
}
```