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.
#include <iostream>
usingnamespace 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
}
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.
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.