Hi, doing an assignment that involves floating point numbers and integers. What I am supposed to do is make the program use either integers or floating point numbers depending on the input from the main function. This is not user input, but coded into main. I had the idea to use a union to help with this, but I am not sure about that, or how to go about it. I was told that I was also, along with the union, supposed to come up with a function to set the variable type. Right now, and I am not sure this is even remotely correct is:
union Values{
float x;
int y;
};
If you could tell me how to manipulate the union/data so that the program would use the correct variable type, that would be great. thanks.