0

Can any one tell me what i need to add overhere to output the result

#include <iostream> using namespace std; int addnumbers( int x, int y ,int b , int a ) { int result = x + y + b + a ; return result; ; } int main() { int x; cout << "enter the 1st n : " ; cin >> x ; int y; cout << "enter the 2nd n : " ; cin >> y ; int b ; cout << " enter the 3rd n : " ; cin >> b ; int a ; cout << " enter the 4th n : " ; cin >> a ;

28th Dec 2020, 12:51 PM
Abdelmalek Serrik
2 Answers
+ 4
Call the function addnumbers in main() like : cout<<addnumbers(x,y,b,a);
28th Dec 2020, 12:56 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
Eon Both of our logics are correct. C.Abdou can either output result in the addnumbers () itself or by printing the returned value of result in main() ... Btw cout is the standard statement to display output to console in cpp .
28th Dec 2020, 1:01 PM
Alphin K Sajan
Alphin K Sajan - avatar