+ 1
I wrote this code in c to convert normal time to military time is there anything i can do to make it simpler ? please help me
24 Answers
+ 2
12:30 AM outputs 0:30 should be 00:30
+ 2
Yeah I fixed it 😅 ,...anything else sir?
+ 1
I Fixed that sir😁 👍thank you, ... Can i make it any simpler 😅?
+ 1
Ok i will give it a try but it's 3:00 am over here in India ,.. so i guess I will do it after I wake up 😊 thanks for answering sir
+ 1
The code coach input for this challenge will gives the same format consistently. Where there aren't any leading zeros and there is always a space between AM or PM which are always capitalized. I'm sure you could reduce your code by using built in functions etc, but that's up to you. I would however suggest avoiding the use of goto. Instead put that code in a function and call it.
+ 1
Ok sir thank you very much for the advice 😊😊
+ 1
Check this code i think it works(i checked several variants) and it is a little bit smaller then yours))))
https://code.sololearn.com/cKJHCiv4vSzG/?ref=app
+ 1
https://code.sololearn.com/c9wa4CZXUC0F/?ref=app
You may try checking this out.
+ 1
I've done it without including <string.h>. You can check this out 🙃
https://code.sololearn.com/c4CcaO3nT71N/?ref=app
0
Proble! Woth entering a lower case pm
0
There are a lot of other cases to check 02:30pm, 02:30 pm, 2:30pm, 2:30 pm also with am
0
But such checks gives possibility to think in scope of writing production code. And such experience is very usefull in future
0
Yes it can be simplified. But i do not remember c function since i wrote on c++
you need just parse full str via scanf with 2 integer and 1 string param.
analyze am or pm(make upper the string and check on A or P) and make manipulation i thin +12 or -12 just math calculation need
0
Wow iam new to programing and I learnt a lot from your code sir😲 thank you very much ,.. I'll try to make my codes more efficient from now on😀 have a nice day ,... Happy coding 😁
0
Turns out I was just over complicating things 🤦🏻♂️ ,.. thanks for sharing this code 😊😊
0
Hima, good code, but you you have not some checks on correction!!!! As example is ok, but in comercial writing such code not aproved via qa department
0
So always try write codes with all possible check for future.
0
george what you really meant by "checks"? The code is meeting all the required conditions.
0
Hima enter the 12:30 without am and pm!!!!
enter 06:20 pm (small symbols) this checks need to be take to an account.
so in general code is good in all aspects if you enter correct AM/PM time, and for example,ot is great but in comercial writing such code will not be approved by QA department.
0
george Why should one do that in the first place ? The code is in accordance with the Input format and this is just wise thinking and making use of format specifiers at its best .