Just need to seek for some assistance as this is a task for C programming in linux - any hint, few sentences or cheat sheet would be most welcome to assist in this small task I am having difficulties with.....here is the scope of it in a quote box.
Quote
Design and implement an algorithm that will prompt for and receive the time expressed in 2400 format, (e.g 2305 hours), convert it to 12-hour format (e.g 11:05p.m) and display the new time to the screen. Your program is to repeat the processing until a sentinel time of 9999 is entered.
I attempted this in code, at some point - it seems that I am stuck
#include <stdio.h>
int main()
{
int time;
//read numbers
printf("Enter the time in 2400 format>\n");
scanf("%d\n", &time);
//converting
if (time > 1200 )
printf("The time is %d\n", time);
else
printf("The time is %d\n", time);
//exit program
return(0);
}
Few things I am attempting is to change 2400 to 1200 hours, which is I am not sure and the other is the ':' printed out in the output. Does anyone know how?
(pssttt.... what about the sentinel execution? Does this involve with a while loop or something relevant?)


Sign In
Create Account


Back to top









