I have been getting weird answers when decimal numbers are input into a, b, or c variables in my quadratic equation program. I was wondering if anyone would be able to sift through some of my decimal related things in it. I wanted it to find if any of the numbers had decimals, and if any did, multiply all three variables by the smallest decimal's multiple-of-ten-that-would-make-it-zero.
An example of the problem:
a = 1, b = -.02, c = -1.2
output:
240.01 and -240.03
The program also accounts for imaginary numbers.
Here are the areas that I think may be problem areas:
The one of the problems is with your globals and their supposed "initialization" in main()
Look at the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
int x = 100;
void printGlobal()
{
std::cout << x << std::endl;
}
int main()
{
int x = 500;
std::cout << x << std::endl;
printGlobal();
return 0;
}