I need some assistance with my code. I figured it out and have it working for the most part. I just need some help in the carrying function where all the numbers that where added we carried over with paper and pencil type arithmetic. My biggest problem now is trying to get the function to open up and print out the preceding 1 that is required. Any assistance would be appreciated.

int main()
{
     int conInput1[ARRAY_SIZE] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
     int conInput2[ARRAY_SIZE] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
     int newOutput[ARRAY_SIZE_2] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     double val2;
    
     fillZero(conInput1, conInput2, newOutput);
     addition(conInput1, conInput2, newOutput);
     printResults(conInput1, conInput2, newOutput);
return 0;
}

void fillZero(int conInput1[], int conInput2[], int newOutput[])
{

     //cout << conInput1[ARRAY_SIZE];
     //cout << conInput2[ARRAY_SIZE];
     for ( int i = 0; i < ARRAY_SIZE; i++ )
     {
          newOutput[i] = 0;
          //cout << newOutput[i];
     }
}

void addition(int conInput1[], int conInput2[], int newOutput[])
{    
     for ( int i = 0; i < ARRAY_SIZE; i++ )
     {
          newOutput[i] = conInput1[i] + conInput2[i];
          //cout << conInput1[i] << "input";
          //cout << conInput2[i] << "input";
          //cout < output1[i] << "test";
     
          if (  newOutput[i] >= 10 )
          {
               carry(conInput1, conInput2, newOutput);
          }

     }
}


void carry(int conInput1[], int conInput2[], int newOutput[])
{
     int i;
     int x = 0;

     for ( i = 0; i < ARRAY_SIZE_2 + 1; i++ )
     {
          if ( newOutput[i] >= 10)
          {
               x = newOutput[i] / 10;
               //cout << x << endl;
               newOutput[i] = newOutput[i] % 10;
               //cout << " \n"<< newOutput[i] << newOutput[i];
               newOutput[i-1] = newOutput[i-1] + x;
          }
     }
     
}

void printResults(int conInput1[], int conInput2[], int newOutput[])
{
     cout << endl << endl;
     for ( int i = 0; i < ARRAY_SIZE; i++  )
     {
          cout << conInput1[i];
     }
     cout << endl;
     for ( int j = 0; j < ARRAY_SIZE; j++  )
     {
          cout << conInput2[j];
     }
     cout << endl << "--------------------" << endl;
     for ( int k = 0; k < ARRAY_SIZE; k++  )
     {
          cout << newOutput[k];
     }
     cout << endl << endl;
}

I strongly suggest you add many comments to your code. At the very least, there should be one or two sentences at beginning of every function telling the reader what the function is supposed to do.

You can also give us a sense of what the entire program is supposed to do.

Also, whenever I see something like this:

int conInput1[ARRAY_SIZE] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};

it makes me think something is being done less than efficiently :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.