Type 3 Function Assignment Help

Assignment Help: >> Functions, Arguments and Overloading - Type 3 Function

Type 3

The third type of user defined function passes a few formal arguments to a calling portion of the program and the computed value if there is any, is transferred back to the caller. Data communication among the calling portion of a program and the function block both.

Example:

void main (void)

{

int output(int, int, char);      //function declaration

omt x, y, temp;

------

temp = output( x, y, ch);     // function calling

}

int output( int a, int b, char s)         //function definition

{

int value;

-------

//body of the function

return (something);

}

Sample program:

// A program that find the factorial of a given number

// source file funct4.cpp

# include<iostream.h>

void main(void)

{

long int fact(int);

int x, n;

cout<<"enter any number"<< endl;

cin>>n;

x = fact(n);

cout<<"value ="<<n << "and its factorial =";

cout << x << endl;

}

long int fact(int n)

{

int value = 1;

if (n = = 1)

return (value);

else

{

for(int i= 1; i<= n; i++)

value = value * i

return(value);

}

}

output of the program

enter any integer number

5

value 5 and its factorial = 120

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd