/* Sandra N. Kardaras-Flick 02/15/05 STRUCTS Calculates elapsed time based on user input. */ #include /*struct for start time*/ typedef struct{int hr; int min; int sec;}START; /*struct for end time*/ typedef struct{int hr, min, sec;}END; /*Function prototype*/ void elapsedTime(START s, END t); main(){ START_s; END_t; /*value for do-while loop*/ char repeat='y'; /*DO-WHILE loop with sentinel value*/ do{ /*Prompt the user for input*/ printf("\nSTART TIME:\t(use HH MM SS format)\n\n"); scanf("%d %d %d",&s.hr, &s.min, &s.sec); /*Prompt the user for input*/ printf("\nEND TIME:\t(use SS format)\n\n"); scanf("%d %d %d",&t.hr, &t.min, &t.sec); /*Function call*/ elapsedTime(s,t); /*Prompt user to continue, or to quit*/ printf("\nEnter y to continue, or any other key to quit.\n"); scanf(" %c",&repeat); /*end do-while loop*/ }while (repeat=='y'||repeat=='Y'); return; }/*end main*/ /*Function Definition*/ void elapsedTime(START s,END t){ /*local variables*/ int durationH, durationM, durationS; /*Calculate duration*/ durationH=(t.hr-s.hr); durationM=(t.min-s.min);durationS=(t.sec-s.sec); printf("\nThe elapsed time is: %d Hours, %d Minutes, and %d Seconds\n",durationH, durationM, durationS); }/*end definition*/ 32. /*Sandra N. Kardaras-Flick CH 12, Ex. 26*/ #include /*struct for start time*/ typedef struct{int x; int y;}POINT; /*Function prototype*/ void plane(POINT x, POINT y); main(){ POINT x; POINT y; /*value for do-while loop*/ char repeat='y'; /*DO-WHILE loop with sentinel value*/ do{ /*Prompt the user for input*/ printf("\nCOORDINATE 1:\t(enter the x value)\n\n"); scanf("%d",&x.x); /*Prompt the user for input*/ printf("\nCOORDINATE 2:\t(enter the y value)\n\n"); scanf("%d",&y.y); /*Function call*/ plane(x,y); /*Prompt user to continue, or to quit*/ printf("\nEnter y to continue, or any other key to quit.\n"); scanf(" %c",&repeat); /*end do-while loop*/ }while (repeat=='y'||repeat=='Y'); return; }/*end main*/ /*Function Definition*/ void plane(POINT x, POINT y){ /*local variables*/ int quadrant; /*Calculate duration*/ if (x.x>0&&y.y>0){quadrant=1;} if (x.x<0&&y.y>0){quadrant=2;} if (x.x<0&&y.y<0){quadrant=3;} if (x.x>0&&y.y<0){quadrant=4;} printf("\nThe point is in quadrant %d",quadrant); }