The namespace issue has been explained. The reason why you need to do sum= n1 +n2 after the values have been read from the user is, that C or C++ are no logical languages. sum= n1 +n2 is not a definition but a command that is only performed once with the result saved to sum. So you have to do things in the right order.
using namespace std;
int n1, n2, sum;
cout << "Give the first number:" << endl;
cin >> n1;
cout << "Give the second number:" << endl;
cin >> n2;
sum = n1 + n2;
cout << "The result is...:" << sum << endl;
You also forgot a "<<" operator between "The result is...:" and sum.