Function Calling Trouble

Hi, I'm having some issues understanding these errors, could someone please explain why I'm getting them/ how to fix? Thank you, it's greatly appreciated
errors:
6_1.cpp: In function âint main()â:
6_1.cpp:13:61: error: too many arguments to function âint tripleIt()â
cout << "\nValue returned by tripleIt is " << tripleIt(value); << endl;
^
6_1.cpp:7:5: note: declared here
int tripleIt();
^
6_1.cpp:13:64: error: expected primary-expression before â<<â token
cout << "\nValue returned by tripleIt is " << tripleIt(value); << endl;
^
6_1.cpp:15:23: error: too many arguments to function âint tripleIt()â
value = tripleIt(value)
^
6_1.cpp:7:5: note: declared here
int tripleIt();
^
6_1.cpp:16:1: error: expected â;â before âcoutâ
cout << "In main value now is " << value << endl;
^
6_1.cpp:17:23: error: too many arguments to function âint tripleIt()â
value = tripleIt(value)
^
6_1.cpp:7:5: note: declared here
int tripleIt();
^
6_1.cpp:18:1: error: expected â;â before âcoutâ
cout << "In main value now is " << value << endl << endl;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <cstdlib>
using namespace std;
void printMessage();
int tripleIt();
int main()
{ 
int value = 2;
cout << "Hello from main.\n";
printMessage();
cout << "\nValue returned by tripleIt is " << tripleIt(value); << endl;
cout << "In main value now is " << value << endl << endl;
value = tripleIt(value)
cout << "In main value now is " << value << endl;        
value = tripleIt(value)
cout << "In main value now is " << value << endl << endl;
cout << "Goodbye from main.\n";
return 0;
}
void printMessage()
{
cout << "Hello from PrintMessage.\n";
}
int tripleIt(int someNum)
{
return someNum * someNum * someNum;
}
Last edited on
closed account (E0p9LyTq)
your tripleIt function prototype declaration, int tripleIt(); doesn't match the function's definition, int tripleIt(int someNum)
Yep, that'll do it. Plus semicolons and other stuff but i already have that already figured out. Thanks a bunch. This one is solved and now functions correctily :)))
Topic archived. No new replies allowed.