hi guys!!
The purpose of the program I am trying to do is to have an input number of 6 digits typed in and this should then be printed as an hour minute second format. for example 123456 would be 12:34:56
This is what I have but it isn't working in the slightest..??
include <stdio.h>
int main(int argc, char * argv []) {
int sixdigits;
printf("Enter 24 hour time in HHMMSS format:\n");
scanf("%d", &sixdigits);
int hr = (sixdigits/10000);
int min = ((sixdigits/100)-(hr*100));
int sec = (sixdigits-(hr*10000)-(min*100));
if ((hr>=00 && hr<24) && (min>=00 && min<=59) && (sec>=00 && sec<=59)) {
printf("%d : %d : %d\n", hr, min, sec);
} else { printf("Format must be HHMMSS\n");
}
return 0;
}