return integer from function in C++ by R4R Team

program:

#include < iostream>
using namespace std;
class Myclass
{
public:
int func(int n)
{
return n*n;
}
};
int main()
{
int n,square;
Myclass obj;
cout<<"Enter number to find sqauren";
cin>>n;
square=obj.func(n);
cout<<"sqaure is: "<< sqaure;
return 0;
}


output-

Enter number to find square
3
square is: 9




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!