Answers for "c++ return value from function"

C++
4

return use in c++

Terminates the execution of a function and returns control to the calling function (or to the operating system if you transfer control from the main function). Execution resumes in the calling function at the point immediately following the call
Posted by: Guest on June-01-2021
-1

function return with int c++

#include <iostream>
 
int getValueFromUser()
{
 	std::cout << "Enter an integer: ";
	int input{};
	std::cin >> input;  
 
	return input;
}
 
int main()
{
    int x{ getValueFromUser() }; // first call to getValueFromUser
    int y{ getValueFromUser() }; // second call to getValueFromUser
 
    std::cout << x << " + " << y << " = " << x + y << 'n';
 
    return 0;
}
Posted by: Guest on March-13-2021

Code answers related to "c++ return value from function"

Browse Popular Code Answers by Language