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

i wrote a program #include <iostream> #include <conio.h> using namespace std; vo

ID: 3683229 • Letter: I

Question

i wrote a program

#include <iostream>
#include <conio.h>
using namespace std;

void inputValue1(long int[]);
void inputValue2(long int[]);
void Sum(long int[]);
const int SIZE=30;
void main()
{
   long int val1[SIZE];
   long int val2[SIZE];
   long int total[SIZE];
   inputValue1(val1);
   inputValue2(val2);
   Sum(total);
getch();
}
void inputValue1(long int val1[])
{
   cout<< "Enter first number:";
   for(int i=0; i<SIZE; i++)
       cin>> val1[i];
   return;
}
void inputValue2(long int val2[])
{
   cout<< "Enter the second number:";
   for(int i=0; i<SIZE; i++)
       cin>> val2[i];
   return;
}
void sum(long int total[])
{
   long int i;
   long int val1[30], val2[30];
   for(i<=SIZE;i>=0;i);
   if((val2[i]+val1[i]>9));
   {
       val2[i-1]=val2[i-1]+1;
   }
   total[i]=(val2[i]+val1[i])%10;
   cout<< "The sum of these two integers is :"<<total[i];

its not building or debudding i dont know why the question was

Write a program for the following: Assume that your computer has the very limited capability of being able to read and write only single-integer digits and to add two integers consisting of one decimal digit each. Write a program that can read two integers up to 30 digits each, add these integers together, and display the result. Test your program using pairs of numbers of varying lengths. Hint: Store the two numbers in two int arrays of size 30, one digit per array element. If the number is less than 30 digits in length, enter enough leading zeros (to the left of the number) to make the number 30 digits long. You will need a loop to add the digits in corresponding array elements. Don’t forget to handle the carry digit if there is one! Make sure you test your program with enough test data. Hint: Digits from the large integer values should be read in as characters and then converted to integers one character at a time to be stored in the 31 element integer array. Since the number is large and you cannot input it as an integer.

Explanation / Answer

#include <iostream>
#include <stdio.h>
using namespace std;
void inputValue1( int[]);
void inputValue2(int[]);
void Sum(int[],int[],int[]);
const int SIZE=30;
int main()
{
int val1[SIZE];
int val2[SIZE];
int total[SIZE];
inputValue1(val1);
//inputValue2(val2);
Sum(total,val1,val2);
   return 0;

}
void inputValue1( int val1[])
{
   int i=30,tempArray[30];
   char temp;
cout<< "Enter first number:";
   for(i=0;i<31;i++)
   {
       cin>>temp;
       if(temp!=' ')
           tempArray[i]=temp - '0';
       else
           break;
   }
   i--;
   for(int j=30;j>=0;j--,i--)
   {
       if(i>=0)
           val1[j]=tempArray[i];
       else
           val1[i]=0;
   }
return;
}
void inputValue2(int val2[])
{
int i=30,tempArray[30];
   char temp;
cout<< "Enter second number:";
   for(i=0;i<31;i++)
   {
       cin>>temp;
       if(temp!=' ')
           tempArray[i]=temp - '0';
       else
           break;
   }
   i--;
   for(int j=30;j>=0;j--,i--)
   {
       if(i>=0)
           val2[j]=tempArray[i];
       else
           val2[i]=0;
   }
return;
}
void Sum(int total[],int val1[],int val2[])
{
   int carry=0,temp;
for(int i=30;i>=0;i--)
   {
       temp=val1[i]+val1[i]+carry;
       if(temp>10)
       {
           temp=temp-10;
           carry=1;
           total[i]=temp;
       }
       else{
           total[i]=temp;
           carry=0;
       }
   }
   cout<<"The result is :"<<endl;
   for(int i=0;i<=30;i++)
       cout<<total[i];
}