+ 2

Can someone please show me a conplete code of using functions. I am having a hard time doing them.

Functions

27th Oct 2016, 12:50 AM
Julian Chavez
2 ответов
27th Oct 2016, 1:39 AM
Hector Sulbaran
Hector Sulbaran - avatar
+ 2
#include <iostream> using namespace std; // Function prototype (declaration) int add(int, int); int main() { int num1, num2, sum; cout<<"Enters two numbers to add: "; cin >> num1 >> num2; // Function call sum = add(num1, num2); cout << "Sum = " << sum; return 0; } // Function definition int add(int a, int b) { int add; add = a + b; // Return statement return add; }
28th Oct 2016, 3:41 AM
NIRMAL JOSEPH
NIRMAL JOSEPH - avatar