Hey guys, I am confused on how to do this code. The specifications are in the attachment. It is a word file. This is the code that I have so far. It does not work to what is asked for and I don't know where to go from here.
#include <iostream>
using namespace std;
const int MAXDIGITS = 100;
void inputVLI(int vli[], int& size);
void outputVLI(int vli[], int& size);
void addVLI(int vli1[], int vli2[], int vli3[], int size1, int size2, int& size3);
int compVLI(int vli1[], int vli2[], int size1, int size2);
int main()
{
int size1 = 0, size2 = 0, size3 = 0;
int vli1[MAXDIGITS], vli2[MAXDIGITS], vli3[MAXDIGITS];
inputVLI(vli1, size1);
inputVLI(vli2, size2);
outputVLI(vli1, size1);
outputVLI(vli2, size2);
addVLI(vli1, vli2, vli3, size1, size2, size3);
if(compVLI(vli1, vli2, size1, size2) == 1)
cout << "The first number is larger than the second one." << endl;
else if(compVLI(vli1, vli2, size1, size2) == -1)
cout << "The second number is larger than the first one." << endl;
else
cout << "They are both equal." << endl;
return 0;
}
void inputVLI(int vli[], int& size)
{
cout << "Enter a lot of numbers but less than 100 times." << endl;
for(char digit = '0'; '0' <= digit <= '9'; size++)
{
cin >> digit;
vli[size] = int(digit - '0'); break;
}
}
void outputVLI(int vli[], int& size)
{
cout << "The first set = " << endl;
for(int i = 0; i >= size; i++)
cout << vli[i] << " ";
}
void addVLI(int vli1[], int vli2[], int vli3[], int size1, int size2, int& size3)
{
int sizefinal;
cout << "When you add them together, you get: " << endl;
if(size1 >= size2)
sizefinal = size1;
else
sizefinal = size2;
for(int size3 = 0; size3 <= sizefinal; size3++)
{
vli3[size3] = vli1[size3] + vli2[size3];
cout << vli3[size3] << " ";
}
}
int compVLI(int vli1[], int vli2[], int size1, int size2)
{
int sizefinal;
if(size1 >= size2)
sizefinal = size1;
else
sizefinal = size2;
for(int i = 0; i <= sizefinal; i++)
{
if(vli1[i] == vli2[i])
return 0;
else if (vli1[i] > vli2[i])
return -1;
else
return 1;
}
return 0;
}