Doing a school assignment where I have to read weight and put them in an array. Our teacher insists we use float as the data type as weight can sometimes be in decimals, too.
Why am I getting:
Enter the name: asd
Enter the weight: 23
Enter the name: de
Enter the weight: 45
Enter the name: as
Enter the weight: 55
Name: asd
Weight: 2.8026e-45
Name: de
Weight: 0
Name: as
Weight: 5.88323e-39
These numbers as output when I want to output the exact number read by the compiler?
You may want to look at std::fixed and std::setprecision (iomanip). These let you print floating point and double precision numbers in a more easy to read format.
The last time I used the array element in a selection the compiler gave an error, I must've been using it wrong. It still doesn't solve the main problem, though.