for (k = shortArrSize + 2 ; k < longArrSize + 1; k++)
{
temp = a[k] - 0 - carry; //How do I reference the value for carry from the last for loop?
if (temp > 0)
{
c[k] = temp;
carry = 0;
}
else
{
c[k] = temp + 10;
carry = 1;
}
Just as you would access any variable that is in scope. Here's an example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include<iostream>
int main()
{
int x = 0;
for (int i=0; i<5; i++)
{
++x;
std::cout << "In the loop.... " << x << std::endl;
}
std::cout << "Not in the loop..." << x << std::endl;
return 0;
}