i have a text file with a list of numbers and dates and i want to find the smallest (the numbers are not in order) and display the date
heres what i have so far
1 2 3 4 5 6 7
double smallest;
smallest = 0;
for (int i = 1; i < 30; i++)
if (smallest > report[i].sunshine)
smallest = report[i].sunshine;
cout << "Smallest is " << smallest << endl;
I think the line smallest is = 0 is wrong because it seems to just be outputing that line but it says i need to initialize smallest so whats wrong with the code?
it works fine til i add the code where i want to display the date next to it then
it displays all 30 dates instead of the 1 date with the smallest number