Type 2 Function Assignment Help

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

Type 2

The second category of user defined function passes a few formal arguments to a function but the function does not return back any value to the caller.  It is a one- way data communication among a calling portion of the program and the function block.

Example:

# include<iostream.h>

void main(void)

{

void power(int, int);   //function declaration

int x,y;

-------

power(x,y);

}

void power(int x, int y)       //function calling

{

-------

// body of the function

// there is no value transferred back to the caller

}

Sample program:

// Passing formal arguments with no return statement

// source name: funct3.cpp

# include<iostream.h>

void main(void)

{

void square ( int );    //function declaration

int max;

cout<< "enter a value for n \n";

for ( int i = 0; i <= max; i++)

square( i );

}

void square (int n)

{

float value;

value = n * n;

cout<< "i = "<< n <<"square = "<< value<< endl;

}

output of the program

enter value for n

2

i= 0 square = 0

i= 1 square = 1

i= 2 square = 4

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