C++ Compilation Problems

Ok so my main focus used to be Java but due to me changing my major from a CS BA to a CS BS I'm starting to focus on C++ now. I used Eclipse to program Java and was did exceptionally well in my classes and with independent programs. However, C++ isn't going as smoothly. I'm trying to find a suitable IDE/Compiler to do C++ programs with and I'm using Visual Studio. I'm currently working on a Hailstone Sequence program and I cannot figure out why this simple block of code refuses to compile.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #include <iostream>
using namespace std;

void main(){
	cout << "Hello World" << endl;
	cout << " " << Next(5) << "  " << endl;
	system("pause");
}

int Next(int x){
	if(x % 2 == 0)
		x /= 2;
	else
		x = 3 * x + 1;
	return x;
}
Last edited on
main must return an integer so change the void type with int.
Also put int Next(int); before main().
Topic archived. No new replies allowed.