Return statement in C++ by R4R Team

Return statement in C++ :
-The return statement terminates the execution of a function and returns control to the calling function.
-We control goes on return statement then it return from that function.

program:

#include < iostream>

using namespace std;
int sqaure(int n)
{
return n*n;
cout<<"This is after return";
}
int main()
{
int n,a;
cout<<"Enter number";
cin>>n;
a=sqaure(n);
cout<<"sqaure is: "<< a;
return 0;
}


output-

Enter number
3
sqaure is: 9

-In this program, we call a function 'sqaure()' that return the sqaure of the given number.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!