FUNC.CPP

• 1: #include <iostream.h>


• 2: int Add (int x, int y) {4:


• 3: cout << "In Add(), received " << x << " and " << y << "\n";


• 4: return (x+y); }


• 5: int main() { cout << "I'm in main()!\n";


• 6: int a, b, c;


• 7: cout << "Enter two numbers: ";


• 8: cin >> a;


• 9: cin >> b;


• 10: cout << "\nCalling Add()\n";


• 11: c=Add(a,b);


• 12: cout << "\nBack in main().\n";


• 13: cout << "c was set to " << c;


• 14: cout << "\nExiting...\n\n";


• 15: return 0; }


Output: 


• I'm in main()!
 
• Enter two numbers: 3 5
 
• Calling Add()
 
• In Add(), received 3 and 5
 
• Back in main().
 
• c was set to 8
 
• Exiting... 

No comments:

Post a Comment

free counters