C++ Function example
#include <iostream>
using namespace std;
int getTotal(int, int);
main()
{
int num1,num2,total;
cout << "Enter first number :";
cin >> num1;
cout << "Enter second number :";
cin >> num2;
total=getTotal(num1,num2);
return 0;
}
int getTotal(int a, int b)
{
int result;
result=a+b;
return result;
}
Notes :
int getTotal() means that this functions returns an integer type variable.
In Linux, compile using this command
g++ yourfile.cpp -o yourfile.exe
1 Comments:
useful post about C++ Function.
my site
Post a Comment
<< Home