function return with int c 2b 2b

Solutions on MaxInterview for function return with int c 2b 2b by the best coders in the world

showing results for - "function return with int c 2b 2b"
Flavien
02 Mar 2016
1#include <iostream>
2 
3int getValueFromUser()
4{
5 	std::cout << "Enter an integer: ";
6	int input{};
7	std::cin >> input;  
8 
9	return input;
10}
11 
12int main()
13{
14    int x{ getValueFromUser() }; // first call to getValueFromUser
15    int y{ getValueFromUser() }; // second call to getValueFromUser
16 
17    std::cout << x << " + " << y << " = " << x + y << '\n';
18 
19    return 0;
20}
21