void GetDay()
{ int i = 0;
cout << "Input the Day: ";
cin >> Today.day;
cout << "Input tomorrow’s day: ";
cin >> Tomorrow.day;
// A while loop can be used to input and store values in the array of structures
while (i < 10) {
cout << "Input a Day: " << endl;
cin >> SomeDate[i].day; //Input the day member of the i th element of the structure array
++i; // increment loop counter
}
return;
}
void GetYear()
{
cout << "Input the Year: ";
cin >> Today.year;
return;
}
void PrintToday()
{
cout << Today.month << " " << Today.day << ", " << Today.year << endl;
cout << Tomorrow.month << " " << Tomorrow.day << ", " << Today.year << endl;
return;
}
int main( )
{
GetDay();
GetMonth();
GetYear();
PrintToday();
return 0;
}
//Assignment: An array of structure variables can be very useful, especially in maintaining records.
//You see above how to declare such an array. Your assignment is to modify this program to implement
//an array of structured variables that store 5 dates: The day before yesterday, yesterday, today,
//tomorrow, and the day after tomorrow. Then modify (or implement a new) function to print the 5 dates.
//Note: you may do this assignment anyway you wish and with any number of functions you wish.

Leave a Reply