0

i am getting errors when i compile this program

#include <iostream>
#include <cctype>

using namespace std;

const int MAX_DIGITS = 20;

int size;              // number of digits in the integer
int digit[MAX_DIGITS]; // the digits stored in reverse order

void inputBigInt (int a[], int& sizeA);
/


void outputBigInt(int a[], int sizeA);


void add (int a[], int sizeA, int b[], int sizeB, int sum[], int& sizeSum);


int main()
{
int a[MAX_DIGITS];
int sizeA;
int b[MAX_DIGITS];
int sizeB;
int sum[MAX_DIGITS];
int sizeSum;
char ans;
	do
	{
    
		void inputBigInt ( a[MAX_DIGITS], sizeA);

		void add ( a[MAX_DIGITS], sizeA, b[MAX_DIGITS], sizeB, sum[MAX_DIGITS], sizeSum);

		void outputBigInt(a[MAX_DIGITS], sizeA);

		cout << "\n Do you want to run this program again? (y,n)";
		cin >> ans;
	} while (ans =='y' || ans == 'Y');
     return 0;
}





void inputBigInt (int a[], int& sizeA)
{
	cout<< "Enter up to 19 digits and than press enter.";
	for(char x; x< MAX_DIGITS;x++)
		cin>> a[x];
}
void add (int a[], int sizeA, int b[], int sizeB, int sum[], int& sizeSum)
{
	int x, carry=0, stop, temp;

	if (sizeA > sizeB)
		stop=sizeA;

	else 
		stop=sizeB;

	for (x=0; x<= stop && x< size; x++)
	{
		temp = a[x] + b[x]+ carry;

		if (temp< 10)
		{
			carry=0;
			sum[x]=temp;
		}
		else 
		{
			carry=1;
			sum[x]=temp-10;
		}

		if (carry !=0)
		{
		//overflow
		
			sizeSum=0;
		}
	}
}




void outputBigInt(int a[], int sizeA)
{
	for(int x=size-1;x>=0;x--)
		cout<< a[x];
}

at each of the parts in red my compiler is giving me the same two errors
1. illegal use of type 'void' 2. too many initializers

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by uberian22
1

You can't use the datatype when calling the functions, just get rid of the voids *on those lines only* not in the declaration/defintions, and I think that will solve that specific problem.

Edited by BigTito89: n/a

0

my next question is how to take my user input in char and convert it to int

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.