English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

What are the different forms of function return? Explain with example.

Advertisements
Advertisements

Question

What are the different forms of function return? Explain with example.

Answer in Brief
Advertisements

Solution

Different forms of User-defined Function declarations:

Function without return value and without parameter
The following program is an example of a function with no return and no arguments passed.
The name of the function is display( ), its return data type is void and it does not have any argument.

#include <iostream>
using namespace std;
void display( )
{
cout<<“Function without parameter and return value”;
}
int main()
{
display( ); // Function calling statement//
return(O);
}

Output :

Function without parameter and return value
A Function with return value and without parameter
The name of the function is display(), its return type is int and it does not have any argument. The return statement returns a value to the calling function and transfers the program control back to the calling statement.

#include <iostream>
using namespace std;
int display( )
{
int a, b, s;
cout<<“Enter 2 numbers:
cin>>a>>b;
s=a+b;
return s;
}
int main( )
{
int m=display( );
cout<<“\nThe Sum=”<<m;
return(0);
}
OUTPUT :
Enter 2 numbers: 10 30
The Sum = 40

shaalaa.com
Returning from Function
  Is there an error in this question or solution?
Chapter 11: Functions - Evaluation - Section - D [Page 205]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 11 TN Board
Chapter 11 Functions
Evaluation - Section - D | Q 3. | Page 205
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×