C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// code to convert 12 hour format
// time to 24 hour format time :
/*
input = hour , min , and AM or PM.
output = hour , min in 24 hour format.
*/
#include <stdio.h>
#include <string.h>
int main()
{
int h = 0, m = 0;
char t[3];
scanf("%d %d%*c", &h, &m);
fgets(t, 3, stdin);
if (!strcmp(t, "PM")) h = h + 12;
printf("%02d:%02d\n", h, m);
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run