




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





It happens like the figure shows Consider the figure above.
from main() function.
Then, control of the program moves back to the main function where the code after the call to the function_name() is executed as shown in figure above. Example 2: User Defined Function C++ program to add two integers. Make a function add() to add integers and display sum in main() function. #include <iostream.h> using namespace std; // تعريف عناصر الدالة int add(int, int);
int main() { int num1, num2, sum; cout<<"Enters two numbers to add: "; cin >> num1 >> num2; // استدعاء الدالة sum = add(num1, num2); cout << "Sum = " << sum; return 0 ; } // تعريف الدالة int add(int a, int b) { int add; add = a + b; // االرجاع return add; } Output Enters two integers: 8
Function Definition
المصادر: www.programiz.com, "++ ي " موسوعة البر مجة بلغة سc++ book