Error in my program

I'm trying to fix an error in my program. The error is
Error C2059 syntax error: '}' Line 69
This is my code.

Thanks in advance.
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
  #include <iostream>
#include <stdlib.h>
#include "operator.h"
#include "readdouble.h"
#include "mathequations.h"
using namespace std;

void main()
{
	double		num1;
	double		num2;
	char		op;
	char		validO[] = "+-*/CcXx";
	bool		isValid;
	bool		flag = true;
	int			clear = 0;
	double		sum;
	cout << "Enter first number: ";
	num1 = readDouble ();
	
	cout << "Enter operator +, -, *, /, X to turn off, or C to clear back to zero: ";
	while (flag)
	{
		cin >> op;
		isValid = readOperator(validO, op);
		if (isValid == 0)
			cout << " Error, please enter correct operator: ";
		else if ((op == 'X') || (op == 'x'))
		{
			cout << "Bye.. Press enter to exit: ";
			exit(0);
		}
		else if ((op == 'C') || (op == 'c'))
		{
			cout << clear << " Enter first number: ";
			cin >> num1;
		}
		else if ((op == '+') || (op == '-') || (op == '*') || (op == '/'))
		{
			cout << "Enter second number: ";
			cout << "Press enter key following the number ";
			num2 = readDouble();
		}
		switch (op)
		{
		case '+':
			sum = Add(num1, num2);
			cout << sum << endl;
			break;
		case '-':
			sum = Sub(num1, num2);
			cout << sum << endl;
			break;
		case '*':
			sum = Mul(num1, num2);
			cout << sum << endl;
			break;
		case '/':
			if ((op == '/') || (num2 == 0))
			{
				cout << " Error, cannot divide by zero ";
			}
			else
			{
				sum = Div(num1, num2);
				cout << sum << endl;
			}
		default:
		}

	}
Last edited on
closed account (48T7M4Gy)
Your default: needs at least a following ;
break; under default. Can add error message too. (if it applies)
Last edited on
Topic archived. No new replies allowed.