Your using the same variable in both your for loops, and incrementing it in both. A simple solution would be to modify your first for loop, and remove the second:
for (int i = 1; i < upper && fib(i) < 4000000; i++)
{
if ((Fib(i) % 2) == 0)
{
sum = sum + Fib(i);
}
}
As a side note: Your method is extremely inefficient, as you are calculating fib(i) between one and three times per loop. The first method to reduce the calculation time is pretty simple:
for (int i = 1; i < upper && fib(i) < 4000000; i++)
{
int tempFib = Fib(i);
if (tempFib % 2) == 0)
{
sum = sum + tempFib;
}
}
This new code saves the fib when it is first calculated in the loop, meaning its only called twice. You can move the fib(i) < 4000000 statement outside the for loop line and into its own line to reduce it to one Fibonacci call per loop. However this is still far from optimal as you are still calling it once per loop.
After reviewing your code somewhat more, I don't see why you have the prompt for an upper bound. You already have the boundary of fib(i) < 4000000.
My hint is to have one loop calculating the Fibbonaci numbers that at the same time is calculating the sum. This method will result in one Fibbonci calculation, rather than around thirty five.
Iterative method of Fibonacci:
//Calculates the nth Fibonacci number (excluding the first one)
int prev = 1;
int cur = 2;
for( int i = 2; i <= n; ++i){
int temp = prev + cur;
prev = cur;
cur = temp;
}
return cur;