+1 vote
in Class 11 by kratos

Explain the working of functions with arguments and no return values.

1 Answer

+3 votes
by kratos
 
Best answer

The calling function main() gives the function call to the called function by passing arguments or values. Then the called function takes the values and performs the calculations and gives the output in itself but no value will be sent back to the calling function.

For example,

include

void sum (int x,int y)

{

int sum;

sum = x + y;

cout<<"The sum is "<<sum;

}

void main()

{

void main()

{

void sum (int x, int y)

int a,b;

cout <<"enter the two number";

cin>>a>b;

sum (a,b);

}

In the above example, sum() is a user defined function. main() is a calling function gives a function call sum (a, b); with actual arguments a, b. The copy of values of a and b are sent to formal arguments x and y in the called function stim().

The function sum() perform addition and gives the result on the screen by itself. Here no value is sent back to calling function main() can be observed. These kinds of functions are called “Function with argument but no return values”.

...