I'm trying to add numbers that are larger than the max value for an int. So I'm storing the numbers in arrays, however, it isn't even letting me type numbers into my second array from the console. Any suggestions?
# include <iostream>
usingnamespace std;
int main(int argc, char** argv)
{
int *pVar, *qVar, *tVar;
int arraySize;
cout << "Enter array size: ";
cin >> arraySize;
pVar = newint [arraySize];
qVar = newint [arraySize];
for (int i = 0; i < arraySize; i++)
{
cout << "Enter integer " << i+1 << " : ";
cin >> pVar[i];
}
for (int j = 0; j < arraySize; j++)
{
cout << "Enter another integer " << j+1 << " : ";
cin >> qVar[j];
}
tVar = newint [arraySize + 1];
// this one should be altered with "tVar = new int [arraySize];"
for (int k = 0; k < arraySize + 1; k++)
{
// and this loop is dangerous because the pVar[arraySize] does not exist
tVar[k] = pVar[k] + qVar[k];
}
for (int m = 0; m < arraySize + 1; m++)
{
cout << "Sum " << m+1 << " : " << tVar[m] << endl;
// I add this line to show you the last odd value so watch out!
}
// Also you should delete you xVar variables it is a role
delete pVar;
delete qVar;
delete tVar;
return 0;
}