मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता ११

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

Advertisements
Advertisements

प्रश्न

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

थोडक्यात उत्तर
Advertisements

उत्तर

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
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 11: Functions - Evaluation - Section - D [पृष्ठ २०५]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 11 TN Board
पाठ 11 Functions
Evaluation - Section - D | Q 3. | पृष्ठ २०५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×