I have been trying to find a simple way to return 2 values from a function and found online that creating a structure to store the values was the easiest method of doing so. Now I have written the structure and the function I can not figure out how to actually print the structure. I have seen many other posts about this online, but I don't understand the answers to them. Could anybody please explain to me how I can fix my code without using any technical terms (without explanation). Preferably an addition/modification of my current code with some research material on the subject. I am not experienced in coding at all, nor do I have an education centered around coding. I am just doing this in my spare time for a bit of fun.
#include <iostream>
#include <cmath>
struct values {
float value1;
float value2;
};
values quadratic(int a, int b, int c) {
float d = sqrt(b*b - 4*a*c);
float x1 = (-b + d)/2*a;
float x2 = (-b - d)/2*a;
values result = {x1, x2};
return result;
};
int main() {
std::cout << quadratic(1, 2, -1);
};