Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Hackerrank/problem solving/Time conversion
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ int main(){
int ss;
char t[3];
scanf("%d:%d:%d%s" , &hh, &mm , &ss , &t);
if(hh==12){
if(hh==12){ //Converting the hours from 12 hr format to 24hr format
hh=0;
}
if(t[0]=='P'){
hh+=12;
hh+=12; Adding 12 if it is PM
}

printf("%02d:%02d:%02d" , hh , mm , ss);
printf("%02d:%02d:%02d" , hh , mm , ss); //Prinitng the answer



Expand Down