Pejman Moghadam / C-programming

C++ - Simple function example

Public domain


#include <iostream>
using namespace std;

int add(int x, int y)
{
        cout << "Inside function received";
        cout << " x: " << x;
        cout << " y: " << y;
        cout << endl;
        return (x+y);
}

int main()
{
    cout << "In main() function! \n";
    int a,b,c;
    cout << "Enter two numbers: ";
    cin >> a;
    cin >> b;
    cout << "Calling add() \n";
    c = add(a,b);
    cout << "Back in main \n";
    cout << "c is set to " << c << endl;
    cout << "Exiting... \n\n";
    return 0;
}

BY: Pejman Moghadam
TAG: cpp, cin
DATE: 2011-05-28 11:06:43


Pejman Moghadam / C-programming [ TXT ]