+ 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); }
3 Antworten
+ 7
That is because you are returning value but not printing anywhere.
Try using "cout"
Like, cout << addNumbers(4, 5);
+ 2
cout<<addNumbers(4,5);
+ 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;
}