User Defined Function in C++

Download
Download is available until [expire_date]
  • Version
  • Download 84
  • File Size 1.45 KB
  • File Count 1
  • Create Date May 9, 2016
  • Last Updated May 9, 2016

User Defined Function in C++

User Defined Function in C++

User defined simply means created by the programmer to execute a certain command. Programming languages has its own built-in functions that are ready to use but programmers can also create functions that will fit their needs. This is actually the most challenging aspect of programming, how to understand and create your own functions and this program might help you (for beginners).

Happy Coding!

Source code:

#include < iostream >

using namespace std;

int computeSum(double param1=0, double param2=0)
{
    double sum=0;
    sum=param1 + param2;
    cout << "the sum is: " <<  sum  << endl;
    return sum;
}

int getInput()
{
   double firstnum, secondnum;
   cout << "enter first num" << endl;
   cin >> firstnum;
   cout << "enter second num" << endl;
   cin >> secondnum;
   computeSum(firstnum, secondnum);

}
int main()
{
    getInput();
    return 0;
}
, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.