Compiler errors

I cannot see why this will not compile. I got 24 errors.

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
// The program will read two integers form the user's input and compare those //
// two integers and subtract the smaller integer number from the large integer number. //

#include <iostream>
using namespace std;
int main()

	int first;
	int second;
	int difference;
	int different;
	cout << "Enter the first integer number ";
	cin >> first;
	cout << "Enter the second integer number ";
	cin >> second;
	if (first < second)
	{
		different = second - first;
	 cout << "You entered ";
	 cout << second << " and " << first << endl;
	 cout << "The difference between the second number and the first number is ";
	 cout << different << endl;
    }
	else
	{
	  difference = first - second;
	  cout << "You entered ";
	  cout << first << " and " << second << endl;
	  cout << "The difference between the first number and the second number is ";
	  cout << difference << endl;

	}
	return 0;
}
Last edited on
First of all, you don't have your main function bracketed correctly. On line 6, try this instead:

int main(){


EDIT: Just by adding that bracket, the program compiles and runs correctly.
Last edited on
Thank you very much. I am trying to understand C++, but it is very different.
No problem! I understand completely how hard it is to see one little thing amongst the rest of your code. You were very, very close to finished, though, so good job!
Topic archived. No new replies allowed.