Hi, first post...I am writing a program for simpsons rule for numerical estimation of integrals, wiki here , and I finally got the code to execute with no errors. Now I am just getting a blank black box with no results. Any help? Thanks in advance.
// hw2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <math.h>
double f_int(double x);
double I_simpson(double a, double b, int n);
int main()
{
double d = I_simpson(0, 0.05, 4);
std::cout << d ;
_getch();
return 0;
}
double f_int(double x)
{
// function
return exp((-x*x)/2);
}
double I_simpson(double a, double b, int n)
{
double h = (b-a)/n;
double I_simpson;
int i = 1;
I_simpson = f_int(a)/6 + f_int(b)/6;
for ( i ; (n-1) ; i++)
{
I_simpson = I_simpson + f_int(a + i * h)/3;
}
for (i ; n ; i++)
{
I_simpson = I_simpson + (2/3)*f_int(a + (i - 1/2)*h);
}
I_simpson *= h;
return I_simpson;
}