Function is not executing
I'm just starting out learning how to code. I can't figure out why the function doesn't execute.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class SnowInfo
{
public:
int date;
double inches;
};
void bubbleSort(SnowInfo, int);
int main()
{
int size = 7;
SnowInfo snowinfo[size];
string month;
int start, end;
cout << "What is the name of the month for which you are recording data? ";
cin >> month;
cout << endl << endl << "What is the start date of the period being measured? ";
cin >> start;
cout << endl << endl << "The end date? ";
cin >> end;
cout << endl << endl << endl;
for (int count = 0; count < size; count++)
{
int vari1;
double vari2;
cout << "Enter the date: ";
cin >> vari1;
cout << endl<< endl;
snowinfo[count].date = vari1;
cout << "Enter the snow depth on this date: ";
cin >> vari2;
cout << endl << endl;
snowinfo[count].inches = vari2;
}
void bubbleSort(SnowInfo snowinfo[], int size);
cout << "Snow report " << month << " " << start << " - " << end << endl;
cout << right << setw(8) << "Date" << setw(8) << "Base" << endl;
for (int count = 0; count < size; count++)
{
cout << right << setw(7) << snowinfo[count].date << setw(9) << snowinfo[count].inches << endl;
}
return 0;
}
void bubbleSort(SnowInfo snowinfo[], int size)
{
SnowInfo temp;
bool swap;
cout << "Function" << endl;
do
{
swap = false;
cout << "do" << endl;
for (int count = 0; count < (size - 1); count++)
{
cout << "for" << endl;
if (snowinfo[count].inches > snowinfo[count+1].inches)
{
cout << "if" << endl;
temp = snowinfo[count];
snowinfo[count] = snowinfo[count +1];
snowinfo[count +1] = temp;
swap = true;
}
}
}while (swap);
}
| |
Line 54 is not how you call (use) a function.
Try bubbleSort(snowinfo[], size);
Thank you so much!
Topic archived. No new replies allowed.