cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
moving the value of an int
moving the value of an int
Mar 13, 2012 at 8:04pm UTC
drhingle
(28)
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
Mar 13, 2012 at 8:06pm UTC
ResidentBiscuit
(4459)
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.