Passing Arguments

Hey guys;

I was hoping you guys could explain passing arguments in a good way. I understand how to do it, but I don't understand why I am doing it. If anyone could give a good example of why they are needed that would be very appreciated.
Basically you use subfunctions when ever code has to be repeated. And a good example would be say you need to constantly find the area of a rectangle in your program instead of typing area = l * w; several times we can just call something like area( l , w ); it is barely a change but when you have really large functions and formulas it can save hundreds of lines of code.

1
2
3
4
int area( int length , int width )
{
    return( length * width );
}
This should answer all of your questions about arguments and functions.
http://www.cplusplus.com/doc/tutorial/functions/
And actually read the article, this site has well written documentation about the language.
Topic archived. No new replies allowed.