Expected unqualified-id before {

I keep getting the same error message, which means I can't even try to run my program., right before that very first { on line 1. What am I doing wrong?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <iomanip>

using namespace std;

const int MAX_DIGITS = 20;
//fetches a sequence of digits from the input,
//converts to integer values, records size
void input( int number[], int& size);
//displays the Large_integer's digits in correct order
//on the screen
void output( const int number[], int size);
//input: two large integers
//output: a large integer that is the sum of the inputs
void add( int first[], int first_size, int second[],
          int second_size, int sum[], int& sum_size);


int main()
{
    //Design decision: lower indices correspond
    //to lower order digits
    using namespace std;
    //decalare arrays
    int first[MAX_DIGITS+1];
    int first_size; //number of digits first_size
    int second[MAX_DIGITS +1];
    int second_size;
    int sum[MAX_DIGITS +1];
    int sum_size;
    //declare type for final answer
    char answer;
    
    for(int i = 0; i < MAX_DIGITS - 1; i++)
    {
        first[i] = 0;
        second[i] = 0;
        sum[i] = 0;
    }
    //execute do-while loop until users indicates exit by entering 'n' or 'N'
    do
    {
        //user input for first integer
        input(first, first_size);
        //user input for second integer
        input(second, second_size);
        //add the arrays
        add(first, first_size, second, second_size, sum_size);
        //display ints and sums
    }
        while (answer == 'y' || answer == 'Y');
        
        system("pause");
        return EXIT_SUCCESS;
    {
    
    cout << "Large integer summing program " << endl;
    cout << "Please enter an integer, 20 digits or less "
    << endl;
    //user input fir first int
    input( first, first_size );
    //print user input
    cout << "you entered " << endl;
    output (first, first_size);
    cout << endl;
    cout << "Enter another integer, 20 digits or less" << endl;
    //user input for secind int
    input( second, second_size );
    //print user input
    cout << "you entered " << endl;
    output (second, second_size);
    cout << endl << endl;
    
    //add the arrays
    add(first, first_size, second, second_size, sum_size);
    //display ints and sums
    cout << "The sum is: " << endl;
    output(sum, sum_size );
    cout << endl;
    }
    return 0;
}
}
Last edited on
Get rid of the braces on lines 1 and 86.
If I do that it tells me "add" doesn't have matching function
You're not passing a sum array in your calls.
Topic archived. No new replies allowed.