Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have some problem of my project. why i input the correct number but the output

ID: 3577408 • Letter: I

Question

I have some problem of my project. why i input the correct number but the output show the last number of second is 15a0

and the other problem is the sum can't over 10 digits , yet my projecy can't limit it.

This program to perform addition of two hexadecimal numerals each with up to 10 digits if the result addition is more than 10 digits long, then simply output "Addition Overflow" and not the result of the addition. using arrays to store hexadecimal numerals as arrays of characters

#include <iostream>
#include <string>
#include <cstdlib>
#include <conio.h>
using namespace std;
const int MAX = 11;
int overflowFlag=0;
void get_number ( char input[ MAX]);
// TO get the hexadecimal numerals
void output_number ( char input [MAX]);
// TO display the number
void sum_number ( char input_1[MAX], char input_2[MAX], char input_sum [MAX]);
// to calculate the sum of two input number
int main ()
{
    // Variable declaring
    char ans, ans1;
    cout << "This program is calculate the sum of two hexadecimal numerals "
         << "each with up to 10 digits ";


    do
    {
        system("CLS");
        char input_n1 [MAX] = {'0','0','0','0','0','0','0','0','0','0','0'}; // FOR repeat , we had to let the char = 0;
        char input_n2 [MAX] = {'0','0','0','0','0','0','0','0','0','0','0'};
        char input_sum [MAX-1] = {'0','0','0','0','0','0','0','0','0','0'};
        // get the input of the user
        cout << "The hexadecimal numerals include 0 - 9 and letter a b c d e f ";
        cout << "Please enter the first hexadecimal numeralse (no space ) : ";
        get_number(input_n1);
        cout << endl;
        cout << "Please enter the second hexadecimal numeralse (no space ): " ;
        get_number(input_n2);
        // sum of input n1 and input n2
        sum_number ( input_n1, input_n2 , input_sum );
        // display the first number and second number
        // the sum of total
        if(overflowFlag==0)

        {
            cout << "The sum of ";
            output_number (input_n1);
            cout << " and ";
            output_number (input_n2);
            cout << " IS " ;
            output_number (input_sum);
       }
       else if (overflowFlag == 1)

        {
            cout << "Addition Overflow" << endl;
        }

       cout << endl;
       cout << "Do you want to continue it ";
        cout << " Please enter yes = 'Y' or No 'N' and press ENTER key ";
        cout << "only one character : ";
        ans=getch();
        cout << ans;
        cout << endl <<endl;

    }while ( (ans == 89 || ans == 121 ) ) ;


    return 0;
}
void get_number(char input[MAX] )
{
//Write a C++ program to perform addition of two hexadecimal numerals each with up to 10 digits.

//F the result of the addition is more than 10 digis long , then simply outut "Addition Over flow" and not the result for the addition
    char next= '0';
    int n = 1 ;

   input[0] = next;
    cin.get(next);


    while ( n < MAX && next != ' ' )// for 0 to 9 so n < Max
    {
        input [n] = next;
        n++;
        cin.get(next);
    }


    for ( int i = 0 ; i < n /2; i++ )
        // i is from 0
        // n is from 1
        // why is from 0 to n / 2 ?
        // 1 2 3 4 5 6 the n is 6
        // when i < n / 6 = 3 , it is show 1 2 3 so it will change with 4 5 6
    // 1 chang th 6 arr[ 0 ] =1 arr [ n - 1] = 6
    // 2 change the 5 arr [1] = 2 arr [ n - 1 - 1 ] = 5
    // 3 change the 4 arr [ 2] = 3 arr [ n - 1 -1 -1 ] = 4
    // for the list we can find the arr [ i ] change arr [ n - 1 - i ]
        {
            char temp = input[ i];
            input[i] = input[ n - 1- i];
            input[n - 1 - i] = temp;
        }

    // reverse the digits
    // because we add the number is from the last one
    // EX 10 + 12 ======== 0+2 =2 1+1=2 , 22
    // EX 142 + 309 ======== 2 + 9 = 1 4 + 0 + 1 (the low one have sum is add one more) = 5
    // 1+ 3 = 4
    // so 132 + 309 = is not 154 ( had to reverse the digits )
    // 1 5 4 ==== 4 5 1

    // end for loop
    // when list is 1 2 3 4 5 6 7 8 9 i =0 to i < n / 2
    // 9 / 2 = 4 i < 4 so it 1 2 3 4 change the 6 7 8 9
    // because the 1 to 9 5 = ( 1 +9 ) /2 don't change the
    // it is correct
    cin.clear();
}
void output_number( char input [MAX])
{

        for ( int i = MAX - 1 ; i >= 0 ; i--)
            cout << input[i];
}
void sum_number(char input_1[MAX], char input_2 [MAX], char input_sum [MAX] )
{
    int number1 , number2, total;

    int add_to_digit ;
   int remainder =0;

    char temp;

    int num;

    // for i =0 to Max
   for ( int i =0 ; i < MAX ; i++ )
    {
        // if the number is 0 - 9 for the first hex number
        if ( input_1 [i] >= '0' && input_1 [i] < '0' + 10 )
        {
            number1 = input_1 [i] - '0';
        }
        else // for A B C D E F
        {
            // change the the character to uppercase
            temp = toupper(input_1 [i]);
            if ( temp >= 'A' && temp <= 'F')
            {
                number1 = (temp - 'A') + 10;
            }
             else if (temp = 'N')
            {
                break;
            }
            else
            {

                break;

            }
        }
         // if the number is 0 - 9 for the first hex number

        if ( input_2 [i] >= '0' && input_2 [i] < '0' + 10 )
        {
            number2 = input_2[i] - '0';

        }

        else // for A B C D E F
        {
            // change the the character to uppercase
            temp = toupper(input_2 [i]);
            if ( temp >= 'A' && temp <= 'F')
            {
                number2 = (temp - 'A') + 10;
            }
            else if (temp = ' ')
            {
                cin.ignore(temp);
                break;
            }
            else
            {
                cout << "Please enter the second hexadecimal numeralse (no space ): " ;
                get_number(input_2);
                break;
            }
        }
        add_to_digit = remainder;

        total = ( number1 + number2 + add_to_digit ) % 16 ;
        // if the total < = 16 it can show 1 to 16
        remainder = ( number1 + number2 + add_to_digit ) / 16 ;
        // how many in the same digit
        if ( total >=0 && total < 10) // for number is 0 to 9
        {
            input_sum[i] = char ('0' + total);
            num++;
        }

        else if ( total >=10 && total <= 15)
        {
            input_sum[i] = char ('A' + total - 10);
            num++;
        }


    }
    // end the calculate of sum
    // check the sum is over the 10 digit
    if (add_to_digit == 1 && remainder == 1 )
    {
        cout << "Addition Overflow" << endl;
        overflowFlag = 1;

    }// end for if loop

}

Explanation / Answer

char next= '0';
int n = one ;
input[0] = next;
cin.get(next);

whereas ( n &lt; easy lay &amp;&amp; next != ' ' )// for zero to nine thus n &lt; easy lay
  

for ( int i = zero ; i &lt; n /2; i++ )
// i is from zero
// n is from one
// why is from zero to n / a pair of ?
// one a pair of three four five six the n is six
// once I &lt; n / six = three , it's show one a pair of three thus it'll amendment with four five six
// one Yangtze Kiang th six arr[ zero ] =1 arr [ n - 1] = six
// a pair of amendment the five arr [1] = a pair of arr [ n - one - one ] = five
// three amendment the four arr [ 2] = three arr [ n - one -1 -1 ] = four
// for the list we will realize the arr [ i ] amendment arr [ n - one - i ]
temporary worker = input[ i];
input[i] = input[ n - 1- i];
input[n - one - i] = temp;
}
// reverse the digits
// as a result of we have a tendency to add the amount is from the last one
// EX ten + twelve ======== 0+2 =2 1+1=2 , 22
// EX one42 + 309 ======== a pair of + nine = one four + zero + 1 (the low one have add is add one more) = five
// 1+ three = four
// thus 132 + 309 = isn't 154 ( had to reverse the digits )
// one five four ==== four five one
// finish for loop
// once list is one a pair of three four five six seven eight nine i =0 to i &lt; n / a pair of
// nine / a pair of = four i &lt; four thus it one a pair of three four amendment the six seven eight nine
// as a result of the one to nine five = ( one +9 ) /2 do not amendment the
// it's correct
cin.clear();
}
void output_number( char input [MAX])
{
for ( int i = easy lay - one ; i &gt;= zero ; i--)
cout &lt;&lt; input[i];
}
void sum_number(char input_1[MAX], char input_2 [MAX], char input_sum [MAX] )
{
int number1 , number2, total;
int add_to_digit ;
int remainder =0;
char temp;
int num;
// for i =0 to easy lay
for ( int i =0 ; i &lt; easy lay ; i++ )
variety|the amount|the quantity} is zero - nine for the primary hex number
if ( input_1 [i] &gt;= '0' &amp;&amp; input_1 [i] &lt; '0' + ten )
  
else // for A B C D E F
{
// amendment the the character to capital
temporary worker = toupper(input_1 [i]);
if ( temporary worker &gt;= 'A' &amp;&amp; temporary worker &lt;= 'F')
  
else if (temp = 'N')
  
else
  
}
// if range|the amount|the quantity} is zero - nine for the primary hex number
if ( input_2 [i] &gt;= '0' &amp;&amp; input_2 [i] &lt; '0' + ten )
  
else // for A B C D E F
{
// amendment the the character to capital
temporary worker = toupper(input_2 [i]);
if ( temporary worker &gt;= 'A' &amp;&amp; temporary worker &lt;= 'F')
  
else if (temp = ' ')
  
else
  
else if ( total &gt;=10 &amp;&amp; total &lt;= 15)
  

}
// finish the calculate of add
// check the add is over the ten digit
if (add_to_digit == one &amp;&amp; remainder == one )