SolvedFunction Error

Posts 1–5 of 5 · Page 1 of 1
Function Error
I tried to make a basic function that adds three numbers and adds them together but the sum always seems to be 1, can someone help me fi


Code:
#include <iostream>

using namespace std;

int addnumbers(int a, int b, int c)
{
    return a+b+c;
}



int main()
{
   int e,f,g;
   cin >> e;
   cin >> f;
   cin >> g;
   addnumbers(e,f,g);
   cout << addnumbers << endl;



   return 0;
}
the function "addnumbers" is a function, Not a variable. So you need to store a variable with the result of the function. I'm shit at explaining things, I'm more of a hands on person.

I'd HIGHLY recommend you going to watch some beginners tutorials, Or read a book.

Code:
#include <iostream>

using namespace std;

int addnumbers(int a, int b, int c)
{
    return a+b+c;
}



int main()
{
   int e,f,g;
   cin >> e;
   cin >> f;
   cin >> g;
   int dadsLittleSluttyGirl = addnumbers(e,f,g);//STORE IT AS A VAR!!!!
   cout << dadsLittleSluttyGirl << endl;



   return 0;
}
@Hugo Boss. solved
Quote Originally Posted by Silent View Post
the function "addnumbers" is a function, Not a variable. So you need to store a variable with the result of the function. I'm shit at explaining things, I'm more of a hands on person.

I'd HIGHLY recommend you going to watch some beginners tutorials, Or read a book.

Code:
#include <iostream>

using namespace std;

int addnumbers(int a, int b, int c)
{
    return a+b+c;
}



int main()
{
   int e,f,g;
   cin >> e;
   cin >> f;
   cin >> g;
   int dadsLittleSluttyGirl = addnumbers(e,f,g);//STORE IT AS A VAR!!!!
   cout << dadsLittleSluttyGirl << endl;



   return 0;
}
@Hugo Boss. solved
Thanks I understand don't worry, Thank you.

It's just that in my country (Saudi Arabia) no one gives a fuck about English Language, so finding a book about C++ is like uhm.. Breaking the speed of light.

I've been watching thenewboston's tutorials and learning through other means, well I'm not here to bitch but thanks anyways.
Quote Originally Posted by FishyK View Post
Thanks I understand don't worry, Thank you.

It's just that in my country (Saudi Arabia) no one gives a fuck about English Language, so finding a book about C++ is like uhm.. Breaking the speed of light.

I've been watching thenewboston's tutorials and learning through other means, well I'm not here to bitch but thanks anyways.
Glad I can help :P

Best of luck with you learning C++ as well C:
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us