C++ examples for Language Basics:Variable
Using Arguments with Functions
#include <iostream> int add(int x, int y) { // add the numbers x and y together and return the sum std::cout << "Running calculator ...\n"; return (x+y); } int main() /*w w w . j a va 2 s. c om*/ { std::cout << "What is 8 + 5?\n"; std::cout << "The sum is " << add(8, 5) << "\n\n"; std::cout << "What is 7 + 93?\n"; std::cout << "The sum is " << add(7, 93) << "\n"; return 0; }