I had it down, then I thought I could condense the program using functions. Well, it's broken now and looking for some help. I got "An Access Violation (Segmentation Fault) raised in your program." I was like neato....but how.... I'm trying to add to integers with the array of 30 characters.
any direction would help.
Thanks....
#include <iostream>
#include <string>
using namespace std;
const int counter=31;
int value1(int[]);
int value2(int[]);
int sum(int[]);
int main()
{
int i;
int a[counter];
int b[counter];
int c[counter];
value1(a);
value2(b);
sum(c);
system("pause");
return 0;
}
int value1 (int a[])
{
int i;
cout << "Enter a integer less than 30 ";
cin >> a[i];
i=0; i < counter-1; i++;
return a[i];
}
int value2 (int b[])
{
int i;
cout << "Enter a integer less than 25 ";
cin >> b[i];
i=0; i < counter-1; i++;
return b[i];
}
int sum (int c[])
{
int i;
int a[30],b[30];
/*for(i=0; i<counter; i++)
c[i] = a[i] + b[i];*/
for(i = counter; i>=0;i--)
if ((b[i]+a[i]) > 9)
{
b[i-1] = b[i-1] + 1;
}
c[i] = (b[i]+a[i]) % 10;
cout << "The sum of these two integers is: " << c[i];
return c[i];
}