moving the value of an int

How can i move the value of an integer from a block within a block to the outer block.

ex.
total = 1

if (int1 <= int2)
{
cout<< int2;
total += int2;
}

cout << total << " is the total.\n"


How do i get the total in my if statement to move to the total in my final cout statment? Thanks



Uh, it should work. Total is not declared inside the block. I'm guessing your if block just isn't being ran due to the condition not being met. This would cause your total to not change, of course.
Topic archived. No new replies allowed.