It is another long day (or night) at the library preparing for your next round o
ID: 3639124 • Letter: I
Question
It is another long day (or night) at the library preparing for your next round of midterms. You've done your best to avoid any reference to time as you'd rather not know how long you've been staring at your books and notes. Despite your best efforts you are able to see a reflection of the library clock on a near-by wall. Given the time according to reflection (hour and minute) display the actual time.Example1
Enter the observed hour value: 6
Enter the observed minute value: 43
Reflected Time: 06:43
Actual Time: 05:17
Example2
Enter the observed hour value: 15
Enter the observed minute value: 10
Reflected Time: 15:10
Actual Time: 20:50
Explanation / Answer
#include<stdio.h>
int main()
{
int hr,min,flag=0;
printf("Enter the observed hour value:");
scanf("%d",&hr);
printf("Enter the observed minute value:");
scanf("%d",&min);
printf("Reflected Time: %d:%d ",hr,min);
if(min>=30) { min = 30-(min-30);}
else { min = 30+(30-min);}
min = min%60;
if(hr>=12) { flag = 1; hr = hr-12;}
hr = 11-hr;
if(flag==1) hr = hr+12;
printf("Actual Time: %d:%d ",hr,min);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.