Hello everyone,
Could you please explain to me how to write the user defined functions with multiple arguments? (specifically with 2 or 3 input arguments). And also, how to make one function to manipulate different data each time it is called? (for example area of bigger circle minus area of the smaller circle with one findArea function) To be specific, can you show me Prototype, function definition, and function call?
My C++ book doesn't explain it clearly.
Thank you very much

>Could you please explain to me how to write the
>user defined functions with multiple arguments?
There are three patterns for function parameters. First is a function with no parameters:

void foo();

No parameters is described in code using parentheses where there's nothing between them. Next is a single parameter, which is described in code using a variable declaration between the parentheses:

void foo(int bar);

The third pattern applies to all other numbers or parameters, just keep adding variable declarations and separate them with a comma:

void foo(int bar, double baz, string meep);

>how to make one function to manipulate different data each time it is called?
Pass in different values with each call. Those values will be copied into the variables you declare in the parameter list:

#include <iostream>

int add_all ( int a, int b, int c )
{
  return a + b + c;
}

int main()
{
  std::cout<< add_all ( 0, 1, 2 ) <<'\n';
  std::cout<< add_all ( 3, 4, 5 ) <<'\n';
}

There is lots of information on the web that explains those things for you. Just search google

thank you

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.