Hello all, there are two main problems I am having with this program. The first is that I am not sure how to pass the two structure variables (date tom, and date mom) into the function and then have it execute. Also my series of do-while statements and if statements when executed on their own print infinitely, they do print the correct answer just far too many. Help would be great thank you
Code:#include <stdio.h> struct date { int month; int day; int year; }; void larger (struct date, struct date); int main() { struct date tom; struct date mom; puts("Enter a month, day, and year separated by spaces (mm dd yy):\n"); scanf("%d %d %d", &tom.month, &tom.day, &tom.year); puts("Enter another month, day, and year separated by spaces (mm dd yy):\n"); scanf("%d %d %d", &mom.month, &mom.day, &mom.year); larger (struct date tom, struct date mom); system ("PAUSE"); return 0; } void larger (struct date tom, struct date mom){ if (tom.year>mom.year) printf("\nThe larger date is: %d/%d/%d \n\n",tom.month,tom.day,tom.year % 100); else if (mom.year>tom.year) printf("\nThe larger date is: %d/%d/%d \n\n",mom.month,mom.day,mom.year % 100); do{ if (tom.month>mom.month) printf("\nThe larger date is: %d/%d/%d \n\n",tom.month,tom.day,tom.year % 100); else if (mom.month>tom.month) printf("\nThe larger date is: %d/%d/%d \n\n",mom.month,mom.day,mom.year % 100); do{ if (tom.day>mom.day) printf("\nThe larger date is: %d/%d/%d \n\n",tom.month,tom.day,tom.year % 100); else if (mom.day>tom.day) printf("\nThe larger date is: %d/%d/%d \n\n",mom.month,mom.day,mom.year % 100); do{ printf ("\nThe two dates are the same.\n\n"); } while (tom.day==mom.day); } while (tom.month==mom.month); }while (tom.year==mom.year); }



LinkBack URL
About LinkBacks




