What is missing in my code? | Sololearn: Learn to code for FREE!

-2

What is missing in my code?

https://code.sololearn.com/cLWKVJjfszsB/?ref=app

c++

4/13/2021 6:39:08 PM

TeaserCode

2 Answers

New Answer

0

The hour display should have a length of 2. Here's what I'd managed from my limited knowledge of C++: #include <iostream> using namespace std; int main() { int a, b; char c; cin >> a; cin >> c; cin >> b; cin >> c; if (c == 'P') { a = (a + 12) % 24; } if (a < 10) cout << "0"; cout << a << ":"; if (b < 10) cout << "0"; cout << b; return 0; }

0

TeaserCode Your code not working for some cases.. For single digit hour in AM , you should append '0' to show in double digit. 1:00 AM => 01:00 12:00 AM => 00:00 12:00 PM => 12:00