+ 2

Solve this

This code is not working properly. No output given at the time of execution. int addNumbers(int x, int y) { int result = x + y; return result; } int main() { addNumbers(4, 5); }

29th Nov 2019, 12:43 PM
Azan Sarfaraz
Azan Sarfaraz - avatar
3 odpowiedzi
+ 7
That is because you are returning value but not printing anywhere. Try using "cout" Like, cout << addNumbers(4, 5);
29th Nov 2019, 12:57 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
cout<<addNumbers(4,5);
29th Nov 2019, 12:57 PM
Avinesh
Avinesh - avatar
+ 1
Yes using cout will help it return the value you want: int addNumbers(int x, int y){ int result = x + y; cout << result; } int main(){ addNumbers(4, 5); } OR: int addNumbers(int x, int y){ int result = x + y; return result; } int main(){ int value = addNumbers(4, 5); cout << value; }
30th Nov 2019, 3:28 AM
CeePlusPlus
CeePlusPlus - avatar