User Defined Function in C++

User Defined Function in C++

Version
Download 8
Total Views 0
Stock
File Size 1.45 KB
File Type zip
Create Date May 9, 2016
Last Updated May 9, 2016
Download

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;
}

Comments

comments

Leave a Reply

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

*