So when I created a program that takes 2 integers, add them together and write it to the console. The thing is that I'm learning to use multiple classes. The program works but after getting the first integer, the console pauses and only continues after I enter another integer. Can you guys hint/explain me what is going wrong?
int readNumber()
{
cout << "Enter an integer: ";
int x;
cin >> x;
return x;
}
void writeAnswer(int result)
{
cout << "The result is: " << result;
}
int main()
{
int x;
readNumber();
cin >> x;
int y;
readNumber();
cin >> y;
int result = x + y;
writeAnswer(result);
system("pause");
}