'too few arguments to function' error

Ok so I'm probably posting here too much, but I'm learning fast and you guys are really helpful.

I get this error when I build the program, the program will run, but will only run the first function 'variable_a'. The openeing statement will not show, and I get the error 'too few arguments to function' on line 12,13 and 14.

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;

void variable_a (int a); /* Declaration of functions */
void variable_b (int b); /* Declaration of functions */
void variable_c (int c); /* Declaration of functions */

int main()
{
    cout << "This is a quadratic solver" << endl; /* Opening statement will not show?? */

    variable_a(); /* Use of functions */
    variable_b(); /* Use of functions */
    variable_c(); /* Use of functions */

    return 0;
}


void variable_a (int a) /* Function Code */
{
    cout << "Have your quadratic in the form ax^2 + bx + c" << endl;
    cout << "Enter in the value of a and press ENTER" << endl;
    cin >> a;
    cout << "..." << endl;
    cout << "You entered: " << a << endl;
}

void variable_b (int b) /* Function Code */
{
    cout << "Have your quadratic in the form ax^2 + bx + c" << endl;
    cout << "Enter in the value of b and press ENTER" << endl;
    cin >> b;
    cout << "..." << endl;
    cout << "You entered: " << b << endl;
}

void variable_c (int c) /* Function Code */
{
    cout << "Have your quadratic in the form ax^2 + bx + c" << endl;
    cout << "Enter in the value of c and press ENTER" << endl;
    cin >> c;
    cout << "..." << endl;
    cout << "You entered: " << c << endl
}


Thank you for any help you can provide :)

Tom
void variable_a (int a)
You are telling compiler, that you will call function with one argument. However you did not variable_a(); pass any variable to it.

If you just need a local variable, do:
1
2
3
4
void variable_a ()
{
    int a;
    //... 
If you get an error during compilation you will not be able to run it. What runs is probably an older version of the program.

OK, so when would you put something inside the brackets after a function?

Your changes worked ty :)

Tom
basicly if you need to give the function information which it cannot get by itself, so for example if you want to use a local variable of the function main() inside the called function variable_a().
Arguments are values passed from a function call to a function, if you want to make a program to add two things you need to say:

int addition(int x, int y) (function title)

and in the function call addition (a, b) or (5,3) or anything which at that point in the program has been declared (once) and assigned a value at least once.

In your code you don't pass a value to your function and if you did it has no memory set aside to receive the value (int x) for example.

And if it did it has no way to return a value (return statement or reference).

Also it's important to remember the difference between brackets [], braces{} and parentheses () as they all do different things. If you confuse them the compiler will think a variable is a function or a function is an array etc.
In situations like this, google "argument" or "too few arguments to function" for clues. It helps a lot.
@agnophilo

I did but the answers were usually specific, like 'change this bit of code' and since I'm new I really didnt understand the answers.
Topic archived. No new replies allowed.