Ok, but before you can do that you must understand how functions work and how to use them. It is one of the basics of C/C++ programming. You created a function but then didn't use it at all like it was meant to be used, this was why I was completely confused. Did the code I re-wrote for you help you out at all?
Explaining a function, you have 3 parts. The return of the function, the name, and the input variables
1 2
|
void main()
int Something(int x, int y)
|
Here are 2 examples. The first part is the return. In these 2 examples I give, the first one returns nothing (void) and the second one returns an integer that is 32 bit (int). All functions have to return something, even if it returns nothing (which means it returns void).
The second part is the name. The first function is named main while the second one is named Something.
the third part is the input variables which are incased in parenthesis. you can have as many input variables as you like when you create the function but once you do, you must use that amount of variables. In the first function, it takes nothing. You could put void in there to also show this but it isn't needed here like it is in the return part of the function. The second function takes 2 variables, both integers. The function won't allow you to put strings, char*, __int64, or any other type of variable into it, only integers.
There are exceptions to the limit of the third part like the triple period (...) which allows for unlimited input or void pointers which allows any input but that is complicated for this discussion, so for now focus in on functions 101.
When you created findRoots, you created it to use 5 doubles but when you tried to use it, well you declared it in main as a return of int and as one variable of double and then trying to use it as such.
I am probably not explaining this well, which is why I suggested reading up on this matter because it is so basic that I will over complicate it with an explanation making it more of a headache for you in the long run.