I need solution | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need solution

Military Time +50 XP You want to convert the time from a 12 hour clock to a 24 hour clock. If you are given the time on a 12 hour clock, you should output the time as it would appear on a 24 hour clock. Task: Determine if the time you are given is AM or PM, then convert that value to the way that it would appear on a 24 hour clock. Input Format: A string that includes the time, then a space and the indicator for AM or PM. Output Format: A string that includes the time in a 24 hour format (XX:XX) Sample Input: 1:15 PM Sample Output: 13:15

17th Dec 2020, 1:01 PM
Hakam
5 Answers
+ 2
In order to get string as input including the whitespace character, you need getline. http://www.cplusplus.com/reference/string/string/getline/
17th Dec 2020, 1:26 PM
Fermi
Fermi - avatar
+ 2
Hakam then just take input as string and convert parts of it to integers. And before you ask, yes it's very much possible in C/C++.👍
17th Dec 2020, 2:09 PM
Arsenic
Arsenic - avatar
+ 1
First show your attempt here 😊😍
17th Dec 2020, 1:03 PM
Sâñtôsh
Sâñtôsh - avatar
0
I am facing only one problem with this task. I know i need to add 12hrs to the given input, then output the result. My issue is that I don't know how to define what is in the string input. If, for example, the input was an integer, it would be easier to know its value.
17th Dec 2020, 1:10 PM
Hakam
0
I hope someone give me the full solution code, though i didn't quite understand your answers.
17th Dec 2020, 4:38 PM
Hakam