Function generally has return type before it's name. For Example :
int calculateX() {
int x;
cout<<"Enter value for x: ";
cin>>x;
anotherFunction(x)
return x;
}
int
is here return type.And you are calling two functions from your main function. calculateX has a variable of type int named x. So, you can't access x from outside of calculateX scope. But you can return it to your main function and store it in a different variable so that It becomes available in main function. Once It becomes available, you can send it as argument to another function . In your case It should be like this :
int anotherFunction(int valueFromMain)
{
std::cout << valueFromMain << std::endl;
}
int main(){
int returnedFromCalculateX = calculateX(); //You have returned value available on main Function
anotherFunction(returnedFromCalculateX); //Send It to anotherFunction(pass by value)
return 0;
}
You can also send the value as a reference. That needs a bit higher understanding. Please Check : https://www.w3schools.com/cpp/cpp_function_reference.asp for more details.